Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old 05-13-2008, 03:55 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,364
Last Blog:
PHPUnit
Rep Power: 50
John is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of light
Send a message via AIM to John
Default Re: How to take the true name of the site from the URL

Whether you read the first X bytes or the whole file won't make any difference - you still have to create a connection with the remote server. Once you made the connection, you have the entire page content.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 05-13-2008, 06:01 PM
phpforfun's Avatar   
phpforfun phpforfun is offline
Programming God
 
Join Date: Feb 2008
Posts: 541
Last Blog:
ubuntu... do not upgra...
Rep Power: 5
phpforfun will become famous soon enough
Default Re: How to take the true name of the site from the URL

Untitled Document
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 05-13-2008, 09:23 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,364
Last Blog:
PHPUnit
Rep Power: 50
John is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of light
Send a message via AIM to John
Default Re: How to take the true name of the site from the URL

I'm not 100% sure on this, but I believe every website uses favicon.ico, so all you would need to do is check if that exists. Also, if your regular expression finds more than one match, your expected match might not be index one.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 05-13-2008, 09:50 PM
phpforfun's Avatar   
phpforfun phpforfun is offline
Programming God
 
Join Date: Feb 2008
Posts: 541
Last Blog:
ubuntu... do not upgra...
Rep Power: 5
phpforfun will become famous soon enough
Default Re: How to take the true name of the site from the URL

yeah, I need to search for ".ico", get get the full path to it..

Let me explain what im trying to do, basicly im making a virtual browser, that you can login to through any computer, it will emulate firefox, there fore, I want the bookmarks bar, so im trying to get it to get the real .ico and show it, as well as the title of the page.

Also, For the stop button, what I plan on doing is, use this script (Building a Status Bar into a Chromeless Window), the issue is, it needs all the images in a page and throw them in the head of the page in the script, can you help me with a loop to echo each image?

im not sure how to use the 'for' command with preg match for each '<img src='
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java:Tutorial - Tic-Tac-Toe John Java Tutorials 25 02-27-2008 06:41 PM
Top 10 Ways To Promote Your Web Site ravs2k6 Marketing 30 02-02-2008 04:20 AM
Operators clookid PHP Tutorials 1 01-11-2007 08:35 PM
Online RPG For Sale - Predicted PR 5 phb50530 Site Reviews 10 01-10-2007 05:59 AM


All times are GMT -5. The time now is 12:54 AM.

Contest Stats

dargueta ........ 93.00000
John ........ 87.50000
Xav ........ 70.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads