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 parseEmail ($body) {
14 $body = eregi_replace ("([a-z]|[0-9]|_|\.|-)+\@([a-z]|[0-9]|_|-)+(\.([a-z]|[0-9]|_|-)+)*", "<a href=\"../src/compose.php?send_to=\\0\">\\0</a>", $body);
18 function parseUrl ($body) {
19 #Possible ways a URL could finish.
21 $poss_ends=array(" ", "\n", "\r", "<", ">", ".\r", ".\n", ". ", " ", ")", "(",""");
24 #Look for when a URL starts
30 for($i = 0; $i < sizeof($url_tokens); $i++
) {
31 if($where = strpos(strtolower($body), $url_tokens[$i], $start))
34 //$where = strpos(strtolower($body),"http://",$start);
36 # Find the end of that URL
37 reset($poss_ends); $end=0;
38 while (list($key, $val) = each($poss_ends)) {
39 $enda = strpos($body,$val,$where);
40 if ($end == 0) $end = $enda;
41 if ($enda < $end and $enda != 0) $end = $enda;
44 $url = substr($body,$where,$end-$where);
45 #Replace URL with HyperLinked Url
47 $url_str = "<a href=\"$url\" target=\"_blank\">$url</a>";
48 # $body = str_replace($url,$url_str,$body);
49 $body = replaceBlock($body,$url_str,$where,$end);
50 $start = strpos($body,"</a>",$where);