godsfriend
Registered Member
- Dec 27, 2008
- 84
- 39
Hi guys and gals !
Today I found a script, which seemed to be a solution for a quite cool redirection based on the keywords the page is clicked in google f.e. But I always get a parsing error (in line 3, if I delete it for test purposes, then in line 7). Due to the fact, I don't know really php, I would like to ask, if somebody could help.
The code is in one page, but the wraps here needed to be split.
Source:http://how.best-free-information.com/2008/07/how-to-redirect-based-on-referer/
A help would be really great. Thanks.
Second I found here, by searching for solutions a geo targeted redirection, which would be a real powerfull php redirect script, when it could be included in a working version of the one above.
Source:http://www.blackhatworld.com/blackhat-seo/cloaking-content-generators/33511-use-php-redirect-user-based-their-geographic-location.html
But with this script, I get also a parsing error. So I am a little confused how to handle it right.
I appreciate any idea. May GOD bless ya
Thx.
Today I found a script, which seemed to be a solution for a quite cool redirection based on the keywords the page is clicked in google f.e. But I always get a parsing error (in line 3, if I delete it for test purposes, then in line 7). Due to the fact, I don't know really php, I would like to ask, if somebody could help.
PHP:
<?php
$redirectURL = ?http://www.yourdomain.com/index.htm?;
if (isset($_SERVER[?HTTP_REFERER?]))
{
if (strpos($_SERVER[?HTTP_REFERER?], ?Diet?) !== false)
{
$redirectURL = ?http://www.your_diet_affiliate_link.com?;
}
else if (strpos($_SERVER[?HTTP_REFERER?], ?Dog?) !== false)
{
$redirectURL = ?http://www.your_dog_training_affiliate_link.com?;
}
else if (strpos($_SERVER[?HTTP_REFERER?], ?Potty?) !== false)
{
$redirectURL = ?http://www.your_potty_training_affiliate_link.com?;
}
else if (strpos($_SERVER[?HTTP_REFERER?], ?Toddler?) !== false)
{
$redirectURL = ?http://www.your_potty_training_affiliate_link.com?;
}
}
?>
HTML:
<html>
<head>
</head>
<body>
<script type=?text/javascript?>
var gaJsHost = ((?https:? == document.location.protocol) ? ?https://ssl.? : ?http://www.?);
document.write(unescape(?%3Cscript src=?? + gaJsHost + ?google-analytics.com/ga.js? type=?text/javascript?%3E%3C/script%3E?));
</script>
<script type=?text/javascript?>
var pageTracker = _gat._getTracker(?UA-xxxxxxx-xx?);
pageTracker._initData();
pageTracker._trackPageview();
</script>
<!? html redirect ?>
<META HTTP-EQUIV=?Refresh? CONTENT=?1; URL=<?php echo $redirectURL ?>?>
</body>
</html>
The code is in one page, but the wraps here needed to be split.
Source:http://how.best-free-information.com/2008/07/how-to-redirect-based-on-referer/
A help would be really great. Thanks.
Second I found here, by searching for solutions a geo targeted redirection, which would be a real powerfull php redirect script, when it could be included in a working version of the one above.
PHP:
<?php
/**
* Original code from svn://hostip.info/hostip/api/trunk. Optimized & enhanced by Quang Pham @ Saoma, 06.01.07.
*/
function isPrivateIP($ip) {
list($a, $b, $c, $d) = sscanf($ip, "%d.%d.%d.%d");
return $a === null || $b === null || $c === null || $d === null ||
$a == 10 ||
$a == 239 ||
$a == 0 ||
$a == 127 ||
($a == 172 && $b >= 16 && $b <= 31) ||
($a == 192 && $b == 168);
}
function getIP() {
$default = false;
if (isset($_SERVER)) {
$default_ip = $_SERVER["REMOTE_ADDR"];
$xforwarded_ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
$client_ip = $_SERVER["HTTP_CLIENT_IP"];
} else {
$default_ip = getenv('REMOTE_ADDR');
$xforwarded_ip = getenv('HTTP_X_FORWARDED_FOR');
$client_ip = getenv('HTTP_CLIENT_IP');
}
if ($xforwarded_ip != "") {
$result = $xforwarded_ip;
} else if ($client_ip != "") {
$result = $client_ip;
} else {
$default = true;
}
if (!$default) { // additional check for private ip numbers
$default = isPrivateIP($result);
}
if ($default) {
$result = $default_ip;
}
return $result;
}
function showUSContent() {
// show US content here, for ex. Yahoo! ads
}
function showInternationalContent() {
// show international content here, for ex. Google ads
}
function showGeoTargetContent() {
// make a valid request to the hostip.info API
$url = "http://api.hostip.info/country.php?ip=".getIP();
// fetch with curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$country = curl_exec($ch);
curl_close ($ch);
// display according geotarget
if ($country == "US") {
showUSContent();
} else {
showInternationalContent();
}
}
showGeoTargetContent();
?>
Source:http://www.blackhatworld.com/blackhat-seo/cloaking-content-generators/33511-use-php-redirect-user-based-their-geographic-location.html
But with this script, I get also a parsing error. So I am a little confused how to handle it right.
I appreciate any idea. May GOD bless ya
Thx.