Quick Search:
 
 PHP Code: Secure Auto-Link Maker Jump to:  
Category: >> PHP Code >> Secure Auto-Link Maker  

<< lastnext >>

Snippet Name: Secure Auto-Link Maker

Description: A more secure version of the link conversion code which will hopefully make cross site scripting (XSS) attacks more difficult.

Also see:
» Truncate Links Over X Chars long
» Nice 'Read More...' links
» Get Link Text
» Auto Link Maker #2
» Auto Link Maker

Comment: (none)

Language: PHP, MYSQL
Highlight Mode: PHP
Last Modified: March 16th, 2009

<?PHP
 
FUNCTION convert_links($str) {
       $replace = <<<EOPHP
'<a href="'.htmlentities('\\1').htmlentities('\\2').//remove line break
'">'.htmlentities('\\1').htmlentities('\\2').'</a>'
EOPHP;
   $str = PREG_REPLACE('#(http://)([^\s]*)#e', $replace, $str);
   RETURN $str;
}
 
?>


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org