There are 3 urls
I want a place a www.url2.com in in a page of www.url1.com and redirect it to www.url3.com (the script will be in www.url2.com) or when someone clicks on a link in www.url1.com - it goes to www.url2.com and a php script works and redirects to www.url3.com
The site www.url3.com should not be able to track www.url1.com
www.url3.com should only know about www.url2.com here is the php script. Please help me find a way.
Now I place a goo.gl (links to www.url2.com) link in www.url1.com and takes the user to www.url2.com and there the script takes user to www.url3.com But www.url3.com still shows the source url as www.url1.com !!! It can track the first url !! how ?
<?php
// change if you wish
$db = 'urls.sw';
// language/style/output variables
$l_nourl = '<strong>No URL supplied</strong>';
$l_yoururl = '<strong>Your short url:</strong>';
$l_invalidurl = '<strong>Invalid URL supplied.</strong>';
$l_createurl = 'Snip!';
if(!is_writable($db) || !is_readable($db))
{
die('Cannot write or read from file. Pleae CHMOD the url file to 777');
}
$action = trim($_GET['id']);
$action = (empty($action) || $action == '') ? 'create' : 'redirect';
$valid = "^(https?|ftp)\:\/\/([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*(\:[0-9]{2,5})?(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?\$";
if($action == 'create')
{
if(isset($_POST['create']))
{
$url = trim($_POST['url']);
if($url == '')
{
echo $l_nourl;
}
else
{
if(eregi($valid, $url))
{
$fp = fopen($db, 'a');
fwrite($fp, "{$url}\r\n");
fclose($fp);
$id = count(file($db));
$dir = dirname($_SERVER['PHP_SELF']);
$snippedurl = "http://{$_SERVER['HTTP_HOST']}{$dir}/$id";
echo "$l_yoururl <a href='$snippedurl'>$snippedurl</a>";
}
else
{
echo $l_invalidurl;
}
}
}
}
if($action == 'redirect')
{
$urls = file($db);
$id = trim($_GET['id']);
$id = $id - 1;
if(isset($urls[$id]))
{
header("Location: {$urls[$id]}");
exit;
}
}
?>