Page 1 of 1
How can I?
Posted: Thu Mar 04, 2004 3:04 pm
by bigjoe
I am trying to find/create a simple script that will tell me where a coded link lands. For example
http://www.awin1.com/tclick.php?id=11738&mid=72 lands at
http://www.groovychocolate.com
I want to be able to input the awin url and output the groovychocolate url
Any ideas?
Rgds
Posted: Thu Mar 04, 2004 3:46 pm
by geekdesign
I hope I understand what you want so if the does not help can you be a little more specific. You want something like what they are doing.
First somewhere you have a table with some informations of links and whatever where each one has it own ID or something.
Second you create a script I don't know call it redirect.php or somthing like that. In that script you want to do the following.
Code: Select all
<?php
//Connect to database
//You may want to use error checking I am just stopping errors by using the @ sign
$link_id = @mysql_connect("host", "username", "password");
//Select your database
@mysql_select_db("database", $link_id);
//Query for pulling links from table
$query = "SELECT url_link FROM table_name WHERE url_id = '$url_id';";
//Get the results from the query
$results = @mysql_query($query, $link_id);
//Fetch the results
$row = @mysql_fetch_row($results);
//Get the url
$my_url = $row[0];
//Close the database
@mysql_close($link_id);
//Redirect to the page
header("Location: " . $my_url);
exit;
?>
I hope this helps.
Posted: Thu Mar 04, 2004 4:39 pm
by Illusionist
hes nto asking for a script that does it, he is asking for a way to tell where someone else's script redirects to.
Posted: Thu Mar 04, 2004 4:55 pm
by Dr Evil
And if that is the question... the answer is nowere!
These links are NOT coded you are talking about variables being passed in the URL corresponding to links stored in a database.
The onlyway you can know the links is by clicking on them or having access to the db table.
Posted: Thu Mar 04, 2004 5:58 pm
by Weirdan
or by making the request to that page and parse the Location header

. Here is an example:
Code: Select all
$check=$_GET["check"];
$cx=curl_init($check);
curl_setopt($cx,CURLOPT_HEADER,true);
curl_setopt($cx,CURLOPT_NOBODY,true);
curl_setopt($cx,CURLOPT_RETURNTRANSFER,true);
$ret=curl_exec($cx);
preg_match("/Location: (.*)/",$ret,$matches);
echo $matches[1]."\n";
use it as follows:
http://yourhost.com/yourscript.php?chec ... 738&mid=72