@@ 251-256 (lines=6) @@ | ||
248 | public static function auto_link_urls($text) |
|
249 | { |
|
250 | // Finds all http/https/ftp/ftps links that are not part of an existing html anchor |
|
251 | if (preg_match_all('~\b(?<!href="|">)(?:ht|f)tps?://\S+(?:/|\b)~i', $text, $matches)) { |
|
252 | foreach ($matches[0] as $match) { |
|
253 | // Replace each link with an anchor |
|
254 | $text = str_replace($match, html::anchor($match), $text); |
|
255 | } |
|
256 | } |
|
257 | ||
258 | // Find all naked www.links.com (without http://) |
|
259 | if (preg_match_all('~\b(?<!://)www(?:\.[a-z0-9][-a-z0-9]*+)+\.[a-z]{2,6}\b~i', $text, $matches)) { |
|
@@ 259-264 (lines=6) @@ | ||
256 | } |
|
257 | ||
258 | // Find all naked www.links.com (without http://) |
|
259 | if (preg_match_all('~\b(?<!://)www(?:\.[a-z0-9][-a-z0-9]*+)+\.[a-z]{2,6}\b~i', $text, $matches)) { |
|
260 | foreach ($matches[0] as $match) { |
|
261 | // Replace each link with an anchor |
|
262 | $text = str_replace($match, html::anchor('http://'.$match, $match), $text); |
|
263 | } |
|
264 | } |
|
265 | ||
266 | return $text; |
|
267 | } |
|
@@ 280-285 (lines=6) @@ | ||
277 | // Finds all email addresses that are not part of an existing html mailto anchor |
|
278 | // Note: The "58;" negative lookbehind prevents matching of existing encoded html mailto anchors |
|
279 | // The html entity for a colon (:) is : or : or : etc. |
|
280 | if (preg_match_all('~\b(?<!href="mailto:|">|58;)(?!\.)[-+_a-z0-9.]++(?<!\.)@(?![-.])[-a-z0-9.]+(?<!\.)\.[a-z]{2,6}\b~i', $text, $matches)) { |
|
281 | foreach ($matches[0] as $match) { |
|
282 | // Replace each email with an encoded mailto |
|
283 | $text = str_replace($match, html::mailto($match), $text); |
|
284 | } |
|
285 | } |
|
286 | ||
287 | return $text; |
|
288 | } |