aaijay Posted April 21, 2007 Share Posted April 21, 2007 Can any one help me with finding the redirected url such as using fpsocket() or fopen() http://vidz.ebookzi.com/redirect.php i would like to define the redirected url to a variable... <?php $url = $redirectedURL; ?> Thanks in Advance. Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/ Share on other sites More sharing options...
trq Posted April 21, 2007 Share Posted April 21, 2007 Sorry, your question is pretty vague. What exactly are you looking at doing? Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234445 Share on other sites More sharing options...
aaijay Posted April 21, 2007 Author Share Posted April 21, 2007 using some sort of function, i would like to define a variable with the redirected url using php like <?php $pagehandle =@fopen("http://vidz.ebookzi.com/redirect.php","rb"); $redirectedUrl = ?? // i.e http://vidz.ebookzi.com/redirected.php ?> Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234456 Share on other sites More sharing options...
MadTechie Posted April 21, 2007 Share Posted April 21, 2007 whats the goal ? end result? as i still don't know what your trying do to ! Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234459 Share on other sites More sharing options...
aaijay Posted April 21, 2007 Author Share Posted April 21, 2007 well im trying to get the redirected url of this page http://vidz.ebookzi.com/redirect.php and define in to a variable so i could manipulate it anyway i like The php itself open the url and gain the redirected url and define it to a variable hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234461 Share on other sites More sharing options...
fert Posted April 21, 2007 Share Posted April 21, 2007 $_SERVER['HTTP_REFERER']; Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234464 Share on other sites More sharing options...
aaijay Posted April 21, 2007 Author Share Posted April 21, 2007 $_SERVER['HTTP_REFERER']; i dnt understand how this could help? Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234469 Share on other sites More sharing options...
trq Posted April 21, 2007 Share Posted April 21, 2007 Please, read the link in my signature. Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234472 Share on other sites More sharing options...
aaijay Posted April 21, 2007 Author Share Posted April 21, 2007 All i want to know is how to retrieve the redirected URL and define it to a variable. Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234476 Share on other sites More sharing options...
MadTechie Posted April 21, 2007 Share Posted April 21, 2007 and its not going well ... take the advice... Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234481 Share on other sites More sharing options...
aaijay Posted April 21, 2007 Author Share Posted April 21, 2007 All i want to know is how to retrieve the new URL(redirected one) and define it to a variable. Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234491 Share on other sites More sharing options...
trq Posted April 21, 2007 Share Posted April 21, 2007 Sorry, but you fail to explain what you want. All i want to know is how to retrieve the new URL Does this mean the current URL? You need to explain better what it is you want to do. Maybe give an example. Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234494 Share on other sites More sharing options...
aaijay Posted April 21, 2007 Author Share Posted April 21, 2007 i want to define a variable with new url, http://vidz.ebookzi.com/redirect.php --this directs to --> http://vidz.ebookzi.com/redirected.php hence using some sort of code i would like to obtain the url "http://vidz.ebookzi.com/redirected.php" and define it to a variable i think its possible by using the function fsocketopen() $fp = fsockopen( "http://vidz.ebookzi.com/redirect.php", 80, &$errno, &$errdesc); $request = "Referer: "; $url = ?? //Newurl(Redirected url) i.e http://vidz.ebookzi.com/redirected.php some thing like this! hope this explains it Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234502 Share on other sites More sharing options...
aaijay Posted April 21, 2007 Author Share Posted April 21, 2007 such as a fucnction function retrive($redirectpageUrl) { **Some code to find the Reredirected url** return $redirectedURL; } retrive("http://vidz.ebookzi.com/redirect.php "); // which should return-->http://vidz.ebookzi.com/redirected.php Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234516 Share on other sites More sharing options...
Guest prozente Posted April 21, 2007 Share Posted April 21, 2007 See this post Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234624 Share on other sites More sharing options...
aaijay Posted April 21, 2007 Author Share Posted April 21, 2007 Ur my hero prozente it works really well but how come i dont get the redirected url for a flash, im tryng to gain the redirected url of lets say http://www.dailymotion.com/swf/maX6GkyCdEPSl9n5j so my code is <?php error_reporting(E_ALL); $service_port = getservbyname('www', 'tcp'); $address = gethostbyname('dailymotion.com'); $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket < 0) { echo "socket_create() failed: reason: " . socket_strerror($socket) . "\n"; } $result = socket_connect($socket, $address, $service_port); if ($result < 0) { echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n"; } $in = "GET /swf/2nWJZC4oOeGTLbZm1 HTTP/1.0\r\n"; $in .= "Host: dailymotion.com\r\n"; $in .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1\r\n"; $in .= "Accept: text/xml,application/xml,application/x-shockwave-flash,application/xhtml+xml,text/html;text/plain\r\n"; //$in .= "Accept: application/x-shockwave-flash\r\n"; $in .= "Accept-Language: en-us,en\r\n"; $in .= "Accept-Charset: ISO-8859-1,utf-8\r\n"; $in .= "Connection: Close\r\n\r\n"; $out = ''; $data = ''; socket_write($socket, $in, strlen($in)); while ($out = socket_read($socket, 2048)) { $data .= $out; } socket_close($socket); preg_match("/Location: (.*)\r\n/", $data, $matches); //$test = preg_match("/http:\/\/www\.dailymotion\.com\/flash\/flvplayer\.swf\?(.*)+/", $data, $matches); echo $matches[1]; //echo $test; ?> which just returns the Main page url not the redirected one any help please. thanks Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234818 Share on other sites More sharing options...
Guest prozente Posted April 21, 2007 Share Posted April 21, 2007 Change $in .= "Host: dailymotion.com\r\n"; to $in .= "Host: www.dailymotion.com\r\n"; They prefer to use only one URL so anyone who enters dailymotion.com will be told to go to www.dailymotion.com Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234885 Share on other sites More sharing options...
aaijay Posted April 21, 2007 Author Share Posted April 21, 2007 IT WORKS HURREYYYYYYY!! prozente Rocks! thanks soo much. Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-234910 Share on other sites More sharing options...
aaijay Posted May 31, 2007 Author Share Posted May 31, 2007 is there anyway to find the url without using socket_create() or any socket families, such as using fopen ive tried the code below but it won't return any value.. $pagehandle=@fopen("http://www.dailymotion.com/swf/2nWJZC4oOeGTLbZm1/","rb"); $contents = ""; do { $data = @fread($pagehandle, 8192); if (strlen($data) == 0) { break; } $contents .= $data; } while(true); @fclose($pagehandle); preg_match("/Location: (.*)\r\n/", $contents, $matches); return $matches[1]; im using a linux server and the hosting provider doesn't allow any socket family function to execute is there another way to find the redirected url with other function please Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/47979-how-to-find-the-redirected-url/#findComment-265327 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.