a34631437f5a71314ff9b969243229bb4639be10
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", ". ", " ", ")", "(",
38 """, "<", ">", ".<");
41 #Look for when a URL starts
47 for($i = 0; $i < sizeof($url_tokens); $i++
) {
48 if($where = strpos(strtolower($body), $url_tokens[$i], $start))
51 //$where = strpos(strtolower($body),"http://",$start);
53 # Find the end of that URL
54 reset($poss_ends); $end=0;
55 while (list($key, $val) = each($poss_ends)) {
56 $enda = strpos($body,$val,$where);
57 if ($end == 0) $end = $enda;
58 if ($enda < $end and $enda != 0) $end = $enda;
60 if (!$end) $end = strlen($body);
62 $url = substr($body,$where,$end-$where);
63 #Replace URL with HyperLinked Url
65 $url_str = "<a href=\"$url\" target=\"_blank\">$url</a>";
66 # $body = str_replace($url,$url_str,$body);
67 # echo "$where, $end<br>";
68 $body = replaceBlock($body,$url_str,$where,$end);
69 $start = strpos($body,"</a>",$where);