29de29332f9f3fcd976b71fa70eda15844864cc5
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]|[A-Z])|[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 $where = $where - 2; // because we added the ^^ at the begining
54 # Find the end of that URL
55 reset($poss_ends); $end=0;
56 while (list($key, $val) = each($poss_ends)) {
57 $enda = strpos($body,$val,$where);
58 if ($end == 0) $end = $enda;
59 if ($enda < $end and $enda != 0) $end = $enda;
61 if (!$end) $end = strlen($body);
63 $url = substr($body,$where,$end-$where);
64 #Replace URL with HyperLinked Url
66 $url_str = "<a href=\"$url\" target=\"_blank\">$url</a>";
67 # $body = str_replace($url,$url_str,$body);
68 # echo "$where, $end<br>";
69 $body = replaceBlock($body,$url_str,$where,$end);
70 $start = strpos($body,"</a>",$where);