Current time: 02-04-2012, 02:55 AM Hello There, Guest! (LoginRegister)


Post Reply 
Replace raw url text to title
06-21-2009, 02:44 AM (This post was last modified: 07-24-2009 10:32 AM by sushruth.)
Post: #1
Pencil Replace raw url text to title
Hello guys..

I finally decided to make this as code edits and NOT a plugin.. keeping in mindeverything that conflicts the plugin...

See Below :

Edits :
  • Find the lines below in inc/class_parser.php

    PHP Code:
    /*
    options = array(
        allow_html
        allow_smilies
        allow_mycode
        nl2br
        filter_badwords
        me_username
        shorten_urls
    )
    */ 

    Now, Add the code below after the found lines

    PHP Code:
    function urltitlefind($link$text='')
        {
            
    // Ensure $link is a valid URL        
            
    $url $link;
            
            
    $fp = @fopen($url'r');
            if (!
    $fp) {
                
    $title = (!$text $link $text);
                return 
    "(Broken Link)";
            }

            
    // Grab <title>*</title> from the first "chunk" of data
            
    $title url_grab_title($fp);

            
    // No <title> tag in first chunk...    
            
    if (!$title) {
                
    $title = (!$text $link $text);
                return 
    "<a href='$url'>::Link (no title found)::</a>";
            }

            
    // User gave me some text to append to the link title
            
    if ($text) {    
                
    $title .= ': '$text;
            }
            
            return 
    $title;
        }

    function 
    url_grab_title($fp)
        {
            
    // How many bytes to grab in one chunk.
            // Most sites seem to have <title> within 512
            
    $chunk_size 512;

            
    $chunk fread($fp$chunk_size);
            
    $chunk preg_replace("/(\n|\r)/"''$chunk);

            
    // Look for <title>(.*?)</title> in the text
            
    if (preg_match('/<title>(.*?)<\/title>/i'$chunk$matches)) {
                return 
    $matches[1];
            }

            return 
    null;
        } 
  • Now, Find the code below in the same file

    PHP Code:
    $name $url

    Replace this with the code below :

    PHP Code:
    $name urltitlefind($url); 
  • For Link Checking

    Files on the following websites will be checked :

    Quote:rapidshare.com
    megaupload.com
    megashares.com
    sendspace.com
    rapidshare.de
    mediafire.com
    • Find the code below in the Same file

      PHP Code:
      $fullurl strtr($fullurl, array('$' => '%24''^' => '%5E''`' => '%60''[' => '%5B'']' => '%5D''{' => '%7B''}' => '%7D''"' => '%22''<' => '%3C''>' => '%3E'' ' => '%20')); 

      Add the code below after the found code

      PHP Code:
          if(strstr($fullurl,"rapidshare.com")){
              
      $var file_get_contents($fullurl);
              
      $checked $checked 1;
              if(
      strpos($var,"FILE DOWNLOAD")){
              
      $status =  " <font color=\"green\">(file found!)<br></font>";
              
      $working $working 1;
              }
              if(
      strpos($var,"The file could not be found")){
              
      $status =  " <font color=\"red\">(file not found!)<br></font>";  
              }      
              if(
      strpos($var," deleted.")){
              
      $status =  "  <font color=\"red\">(file deleted!)<br></font>";
              }


          } elseif (
      strstr($fullurl,"megaupload.com")){
              
      $var1 file_get_contents($fullurl);
              
      $checked $checked +1;
              if(
      strpos($var1,"Please enter")){
                  
      $status =  " <font color =\"green\">(file found!)<br></font>";
                  
      $working $working 1;
              }
              if(
      strpos($var1,"Unfortunately, the link you have clicked is not available.")){
                  
      $status =  " <font color =\"red\">(file not found!)<br></font>";    
              }
              
          } elseif (
      strstr($fullurl,"megashares.com")){
              
      $var2 file_get_contents($fullurl);
              
      $checked $checked +1;
              if(
      strpos($var2,"Filename:")){
                  
      $status =  " <font color =\"green\">(file found!)<br></font>";
                  
      $working $working 1;
              }
              if(
      strpos($var2,"Welcome to Megashares")){
                  
      $status =  " <font color =\"red\">(file not found!)<br></font>";    
              }
              if(
      strpos($var2,"have the correct URL")){
                  
      $status =  " <font color =\"red\">(file not found!)<br></font>";    
              }
              
          } elseif (
      strstr($fullurl,"sendspace.com")){
              
      $var3 file_get_contents($fullurl);
              
      $checked $checked +1;
              if(
      strpos($var3,"404 Page Not Found")){
                  
      $status =  " <font color =\"red\">(file not found!)<br></font>";    
              
              } elseif(
      strpos($var3,"Sorry, the file you requested is not available.")){
                  
      $status =  " <font color =\"red\">(file not found!)<br></font>";    
              } else {
                  
      $status =  " <font color =\"green\">(file found!)<br></font>";
                  
      $working $working 1;
                  }
          } elseif(
      strstr($fullurl,"rapidshare.de")){
              
      $var5 file_get_contents($fullurl);
              
      $checked $checked 1;
              if(
      strpos($var,"You want to download the file ")){
              
      $status =  " <font color=\"green\">(file found!)<br></font>";
              
      $working $working 1;
              }
              if(
      strpos($var,"File not found.")){
              
      $status =  " <font color=\"red\">(file not found!)<br></font>";  
              }      
              if(
      strpos($var," deleted.")){
              
      $status =  " <font color=\"red\">(file deleted!)<br></font>";
              }
              
          } elseif (
      strstr($fullurl,"mediafire.com")){
              
      $var4 file_get_contents($fullurl);
              
      $checked $checked +1;
              if(
      strpos($var4,"Sharing")){
                  
      $status =  " <font color =\"green\">(file found!)<br></font>";    
                  
      $working $working 1;
              }
              if(
      strpos($var4,"Invalid Quickkey.")){
                  
      $status =  " <font color =\"red\">(file not found!)<br></font>";    
              }
              if(
      strpos($var4,"I want to upload")){
                  
      $status =  " <font color =\"red\">(file not found!)<br></font>";    
              }
          } else {
              
      $status =  "";    
          } 
    • Find this code in the Same File :

      PHP Code:
      $link "<a href=\"$fullurl\" target=\"_blank\">$name</a>"

      Replace this with :

      PHP Code:
      $link "<a href=\"$fullurl\" target=\"_blank\">$name</a> -".$status


Preview :

[Image: or2z4x.jpg]


This will replace any links inserted without a given title, that is like http://www.google.com/ to its title as text, that is, it will be shown as Google
Visit this user's website Find all posts by this user
Quote this message in a reply
06-23-2009, 08:31 PM (This post was last modified: 06-23-2009 08:31 PM by Shadowdare.)
Post: #2
RE: [Release for mybb 1.4.x] Title as Url text
This plugin looks promising and very useful to identify post links easier!

I have a few questions:
1) Can you explain what you mean by "It also, adds any text given by user."
2) What happens if you click the last post link?
3) What happens if you click a permalink of the post (post #)?
Visit this user's website Find all posts by this user
Quote this message in a reply
06-24-2009, 06:30 AM (This post was last modified: 06-24-2009 06:31 AM by sushruth.)
Post: #3
RE: [Release for mybb 1.4.x] Title as Url text
(06-23-2009 08:31 PM)Mushu Wrote:  This plugin looks promising and very useful to identify post links easier!

I have a few questions:
1) Can you explain what you mean by "It also, adds any text given by user."
2) What happens if you click the last post link?
3) What happens if you click a permalink of the post (post #)?


Mushu , This plugin is only for links in a post and not the whole forum links. (It would be awful if i do it for the whole forum and every linked text would be more than 20 chars long which spoils the forum's look)

By Saying "It also, adds any text given by user." I mean it adds the user's text after the title as below (the mod is not installed here and this is just a demo) :

Code:
Code:
[url=http://www.google.com/]UserText[/url]

Result : Google : UserText

EDIT : And any Moderators here, please change the topic's title and link in the forum to "[Release for mybb 1.4.x] Append Url Title to its text"
Visit this user's website Find all posts by this user
Quote this message in a reply
06-24-2009, 09:25 AM
Post: #4
RE: [Release for mybb 1.4.x] Title as Url text
Oh this is cool

Visit this user's website Find all posts by this user
Quote this message in a reply
06-24-2009, 10:08 AM
Post: #5
RE: [Release for mybb 1.4.x] Title as Url text
Thank you Sushruth! I will find this very useful! Wink
Visit this user's website Find all posts by this user
Quote this message in a reply
06-24-2009, 01:31 PM
Post: #6
RE: [Release for mybb 1.4.x] Title as Url text
Very Very good Idea..!

Its promissing and have a great potential on its own...!

Keep it up
Visit this user's website Find all posts by this user
Quote this message in a reply
06-24-2009, 02:07 PM (This post was last modified: 06-24-2009 02:07 PM by Rafael.)
Post: #7
RE: [Release for mybb 1.4.x] Title as Url text
Good, i was looking for something like this Smile

This consume bandwith for my server? Or Excessive resources (querys, etc)?

vBulletin/Wordpress/Magento/MyBB
Developer and Designer
Visit this user's website Find all posts by this user
Quote this message in a reply
06-24-2009, 03:04 PM
Post: #8
RE: [Release for mybb 1.4.x] Title as Url text
(06-24-2009 02:07 PM)rafaweb Wrote:  Good, i was looking for something like this Smile

This consume bandwith for my server? Or Excessive resources (querys, etc)?

Actually, a post does not contain more than 20 links right ?

it does not affect the page loading time untill there are more than 25-30 links in a single post of a thread.
Visit this user's website Find all posts by this user
Quote this message in a reply
07-06-2009, 05:55 AM (This post was last modified: 07-24-2009 10:53 AM by sushruth.)
Post: #9
RE: [Release for mybb 1.4.x] Title as Url text
Again new release :

UPDATE :

Fixed some bugs (major)

and some stupid code (lol)

changed version number to 0.3 Smile


ONE MORE UPDAET IN 5 MINS NOW Smile

FIXED : Clash with auto url parse

Visit this user's website Find all posts by this user
Quote this message in a reply
07-06-2009, 01:54 PM
Post: #10
RE: [Release for mybb 1.4.x] Append Url Title to Text 0.6
Very good, Thanks sushruth

Keep it up
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | MyBB | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication