View Single Post
  #12 (permalink)  
Old 05-13-2008, 06:01 PM
phpforfun's Avatar   
phpforfun phpforfun is offline
Programming God
 
Join Date: Feb 2008
Posts: 790
Last Blog:
Programming "Just a ...
Credits: 102
Rep Power: 9
phpforfun will become famous soon enoughphpforfun will become famous soon enough
Default Re: How to take the true name of the site from the URL

Untitled Do***ent
works great john!!

PHP Code:
    <?
    
if(isset($_POST['url'])){
        
$url $_POST['url'];
        
$content file_get_contents("$url");
        
preg_match('#<title>(.*?)</title>#'$content$title);
        
$title $title[1];
        if(
preg_match('#<link rel="shortcut" href="(.*?)"#'$content)){
            
preg_match('#<link rel="shortcut" href="(.*?)"#'$content$shortcut);
        }
        if(
preg_match('#<link rel="shortcut icon" href="(.*?)"#'$content)){
            
preg_match('#<link rel="shortcut icon" href="(.*?)"#'$content$shortcut);
        }
        
        
$shortcut $shortcut[1];
        
$shortcut ereg_replace("$url"''$shortcut);
        
$titlelength strlen($atitle);
        if(
$titlelength 17){
            
$shorttitle substr($atitle,0,14);
            
$atitle "$shorttitle...";
        }
        if(empty(
$shortcut)){
            
$shortcut "No Shortcut Icon found";
        }

        
$goto str_replace("http"""$url);
        Echo 
"$url<br />$title<br />$shortcut";
    }
    
?>
Thats my test code, am I using the ereg replace wrong? because if you type in toasted penguin, it still has 'http://toastedpenguin.com' in the shortcut text

Edit, I dont think that way is the best way to get the shortcut icon, I need to search for '.ico' and get the image that uses that extension somehow
__________________

Last edited by phpforfun; 05-13-2008 at 06:09 PM.
Reply With Quote