MyBB Community Forums

Full Version: Replace raw url text to title
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
Good, Thanks Smile
Can you post a screen shot.
(2009-07-06, 04:14 PM)T0m Wrote: [ -> ]Can you post a screen shot.

Screenshot ??

Its just uses this fasion to view the links.

Google: Google Earth
btw that is google maps not google earth..
(2009-07-06, 07:53 PM)T0m Wrote: [ -> ]btw that is google maps not google earth..

FYI its an example more than the reality.
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

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

    Now, Add the code below after the found lines

    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

    $name = $url;

    Replace this with the code below :

    $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

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

      Add the code below after the found 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 :

      $link = "<a href=\"$fullurl\" target=\"_blank\">$name</a>";

      Replace this with :

      $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
Do not find this code


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


truth is that file, or someone will have already changed the file
(2009-07-26, 05:53 PM)Walkman 5.0 Wrote: [ -> ]Do not find this code


$fullurl = strtr($fullurl, ......
(trimmed for space)


truth is that file, or someone will have already changed the file

Hey.. it could also be a partial find...

like... find it after the [$name = urltitlefind($url);] code. got it ?
Thanks, I've been looking for something like this since I was one for vB. Nice job. Wink
No probs Ooka.. if you have any requirements or anything for mybb to be done to posts, urls, ect.. let me know.. i just need ideas.. but remember. i can do it only if i know Big Grin
Pages: 1 2 3 4 5