43fcef5c |
1 | <? |
2 | /* URL Passing code to allow links from with in emails */ |
3 | |
4 | $url_parser_php = true; |
5 | |
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; |
10 | return $ret; |
11 | } |
12 | |
175e7218 |
13 | function parseEmail ($body) { |
7151188f |
14 | global $PHPSESSID; |
32b3d87e |
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); |
175e7218 |
16 | return $body; |
17 | } |
18 | |
43fcef5c |
19 | function parseUrl ($body) { |
20 | #Possible ways a URL could finish. |
21 | |
22 | $poss_ends=array(" ","\n","\r","<",". "," "); |
23 | $done=False; |
24 | while (!$done) { |
25 | #Look for when a URL starts |
26 | $where = strpos($body,"http:",$start); |
27 | if ($where) { |
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; |
34 | } |
35 | #Extract URL |
36 | $url = substr($body,$where,$end-$where); |
37 | #Replace URL with HyperLinked Url |
38 | if ($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); |
43 | } else { |
44 | $start = $where + 7; |
45 | } |
46 | } else { |
47 | $done=true; |
48 | } |
49 | } |
50 | |
51 | return $body; |
52 | } |
53 | |
54 | ?> |
55 | |