changed log in method back to using cookies. also session id is now stored
[squirrelmail.git] / functions / url_parser.php
CommitLineData
59177427 1<?php
43fcef5c 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) {
9f2215a1 14 $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);
175e7218 15 return $body;
16 }
17
43fcef5c 18 function parseUrl ($body) {
19 #Possible ways a URL could finish.
20
21 $poss_ends=array(" ","\n","\r","<",".&nbsp","&nbsp");
22 $done=False;
23 while (!$done) {
24 #Look for when a URL starts
25 $where = strpos($body,"http:",$start);
26 if ($where) {
27 # Find the end of that URL
28 reset($poss_ends); $end=0;
29 while (list($key, $val) = each($poss_ends)) {
30 $enda = strpos($body,$val,$where);
31 if ($end == 0) $end = $enda;
32 if ($enda < $end and $enda != 0) $end = $enda;
33 }
34 #Extract URL
35 $url = substr($body,$where,$end-$where);
36 #Replace URL with HyperLinked Url
37 if ($url != "") {
38 $url_str = "<a href=\"$url\" target=\"_blank\">$url</a>";
39 # $body = str_replace($url,$url_str,$body);
40 $body = replaceBlock($body,$url_str,$where,$end);
41 $start = strpos($body,"</a>",$where);
42 } else {
43 $start = $where + 7;
44 }
45 } else {
46 $done=true;
47 }
48 }
49
50 return $body;
51 }
52
53?>
54