2 /* URL Passing code to allow links from with in emails */
4 $url_parser_php = true;
6 function replaceBlock ($in, $replace, $start, $end) {
7 $begin = substr($in,0,$start);
8 $end = substr($in,$end,strlen($in)-$end);
9 $ret = $begin.$replace.$end;
13 function parseUrl ($body) {
14 #Possible ways a URL could finish.
16 $poss_ends=array(" ","\n","\r","<",". "," ");
19 #Look for when a URL starts
20 $where = strpos($body,"http:",$start);
22 # Find the end of that URL
23 reset($poss_ends); $end=0;
24 while (list($key, $val) = each($poss_ends)) {
25 $enda = strpos($body,$val,$where);
26 if ($end == 0) $end = $enda;
27 if ($enda < $end and $enda != 0) $end = $enda;
30 $url = substr($body,$where,$end-$where);
31 #Replace URL with HyperLinked Url
33 $url_str = "<a href=\"$url\" target=\"_blank\">$url</a>";
34 # $body = str_replace($url,$url_str,$body);
35 $body = replaceBlock($body,$url_str,$where,$end);
36 $start = strpos($body,"</a>",$where);