30f95b3d179d058b1271ad24bc6071e36eb800db
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) {
15 $body = eregi_replace ("([a-z]|[0-9]|_|\.|-)+\@([a-z]|[0-9]|_|-)+(\.([a-z]|[0-9]|_|-)+)*", "<a href=\"../src/compose.php?PHPSESSID=$PHPSESSID&send_to=\\0\">\\0</a>", $body);
19 function parseUrl ($body) {
20 #Possible ways a URL could finish.
22 $poss_ends=array(" ","\n","\r","<",". "," ");
25 #Look for when a URL starts
26 $where = strpos($body,"http:",$start);
28 # Find the end of that URL
29 reset($poss_ends); $end=0;
30 while (list($key, $val) = each($poss_ends)) {
31 $enda = strpos($body,$val,$where);
32 if ($end == 0) $end = $enda;
33 if ($enda < $end and $enda != 0) $end = $enda;
36 $url = substr($body,$where,$end-$where);
37 #Replace URL with HyperLinked Url
39 $url_str = "<a href=\"$url\" target=\"_blank\">$url</a>";
40 # $body = str_replace($url,$url_str,$body);
41 $body = replaceBlock($body,$url_str,$where,$end);
42 $start = strpos($body,"</a>",$where);