* Name: hrefs
* Purpose: Highlite all href in text * * @param string * * @return string */ function _makeURL($url) { if (substr($url, 0,7) != 'http://') { $url = 'http://' . $url; }//if return($url); }//function function _check_email($email) { if (eregi("[_0-9a-z-]*(\.[_0-9a-z-])*@([_0-9a-z-])*(\.[_0-9a-z-])*\.([a-z]{2,4})", $email)) { return true; } return false; } function smarty_modifier_hrefs($string, $extras = '') { global $_SERVER; $string = eregi_replace('
', '
', $string); $words = preg_split("/[\s,]+/", $string); $c = count($words); for ($i = 0; $i < $c; $i++) { $w = $words[$i]; if (preg_match('/(http:\/\/|www)([^\/]+)/i', $w)) { // preg_match("/[^\.\/]+\.[^\.\/]+$/", $w, $matches); $t = parse_url($w); $host = $t['host']; $target = 'target="_blank"'; if (strtolower($host) == strtolower($_SERVER['HTTP_HOST'])) { $target = ""; }//if $w = '' . $w . ''; }//if elseif (_check_email($w)){ $w = '' . $w . ''; }//elseif $words[$i] = $w; }//for $res = implode(" ", $words); $string = $res; return($res); } /* vim: set expandtab: */ ?>