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) {
16 This is here in case we ever decide to use highlighting of searched
17 text. this does it for email addresses
19 if ($what && ($where == "BODY" || $where == "TEXT")) {
20 eregi ("([a-z]|[0-9]|_|\.|-)+\@([a-z]|[0-9]|_|-)+(\.([a-z]|[0-9]|_|-)+)*", $body, $regs);
23 $newaddr = eregi_replace ($what, "<b><font color=\"$color[2]\">$what</font></font></b>", $oldaddr);
24 $body = str_replace ($oldaddr, "<a href=\"../src/compose.php?send_to=$oldaddr\">$newaddr</a>", $body);
27 $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);
30 $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);
34 function parseUrl ($body) {
35 #Possible ways a URL could finish.
37 $poss_ends=array(" ", "\n", "\r", "<", ">", ".\r", ".\n", ". ", " ", ")", "(",""");
40 #Look for when a URL starts
46 for($i = 0; $i < sizeof($url_tokens); $i++
) {
47 if($where = strpos(strtolower($body), $url_tokens[$i], $start))
50 //$where = strpos(strtolower($body),"http://",$start);
52 # Find the end of that URL
53 reset($poss_ends); $end=0;
54 while (list($key, $val) = each($poss_ends)) {
55 $enda = strpos($body,$val,$where);
56 if ($end == 0) $end = $enda;
57 if ($enda < $end and $enda != 0) $end = $enda;
60 $url = substr($body,$where,$end-$where);
61 #Replace URL with HyperLinked Url
63 $url_str = "<a href=\"$url\" target=\"_blank\">$url</a>";
64 # $body = str_replace($url,$url_str,$body);
65 $body = replaceBlock($body,$url_str,$where,$end);
66 $start = strpos($body,"</a>",$where);