Go Back   Webmaster Forum > Development > Programming > PHP
REMOVE the ads below !
Reply
 
LinkBack Thread Tools
  # 1 (permalink)
Old
Senior Geek
Posts: 559
Join Date: Nov 2007
iTrader: (0)
Location: Romania
Fetching real URL from a script - 11-30-2007

This function will allow you to get the real URL location for redirects. Example url: http://sitename.com/go.php?urlid=3
PHP Code:
 <?php 

/* Function get hidden link */     
function get_hidden($hiddenlink){ 
    
$info parse_url($hiddenlink); 
    
/* www.hostname.com */ 
    
$fp fsockopen ($info['host'], '80'$errno$errstr30); 
    if (
$fp){ 
        
/* /pagename.php?id=3 */ 
        
$query "GET /$info[path]?$info[query] HTTP/1.1\r\n"
        
/* www.hostname.com */ 
        
$query .= "Host: $info[host]\r\n\r\n"
        
fputs($fp$query);        
        while (!
feof($fp)){ 
            
$buffer .= fgets($fp,128); 
        } 
        
fclose ($fp); 
    } else { 
        return 
NULL
    } 

    
preg_match("/Location: (.+)\n/U"$buffer$url); 
    
$buffer NULL
    return 
str_replace("\r",'',$url[1]); 


$real_link = ('http://www.hotscripts.com/jump.php?listing_id=46675&jump_type=0'); 

?>
Reply With Quote
Reply


Thread Tools



Advertise Here for just $6 per month

vBulletin®, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd. | SEO by vBSEO | Skin developed by vBStyles.com