BBCode::Internal_AutoDetectURLs( $string )
Description
Source
File: bp-forums/admin/parser.php
function Internal_AutoDetectURLs($string) { $output = preg_split("/( (?: (?:https?|ftp) : \\/* (?: (?: (?: [a-zA-Z0-9-]{2,} \\. )+ (?: arpa | com | org | net | edu | gov | mil | int | [a-z]{2} | aero | biz | coop | info | museum | name | pro | example | invalid | localhost | test | local | onion | swift ) ) | (?: [0-9]{1,3} \\. [0-9]{1,3} \\. [0-9]{1,3} \\. [0-9]{1,3} ) | (?: [0-9A-Fa-f:]+ : [0-9A-Fa-f]{1,4} ) ) (?: : [0-9]+ )? (?! [a-zA-Z0-9.:-] ) (?: \\/ [^&?#\\(\\)\\[\\]\\{\\}<>\\'\\\"\\x00-\\x20\\x7F-\\xFF]* )? (?: [?#] [^\\(\\)\\[\\]\\{\\}<>\\'\\\"\\x00-\\x20\\x7F-\\xFF]+ )? ) | (?: (?: (?: (?: [a-zA-Z0-9-]{2,} \\. )+ (?: arpa | com | org | net | edu | gov | mil | int | [a-z]{2} | aero | biz | coop | info | museum | name | pro | example | invalid | localhost | test | local | onion | swift ) ) | (?: [0-9]{1,3} \\. [0-9]{1,3} \\. [0-9]{1,3} \\. [0-9]{1,3} ) ) (?: : [0-9]+ )? (?! [a-zA-Z0-9.:-] ) (?: \\/ [^&?#\\(\\)\\[\\]\\{\\}<>\\'\\\"\\x00-\\x20\\x7F-\\xFF]* )? (?: [?#] [^\\(\\)\\[\\]\\{\\}<>\\'\\\"\\x00-\\x20\\x7F-\\xFF]+ )? ) | (?: [a-zA-Z0-9._-]{2,} @ (?: (?: (?: [a-zA-Z0-9-]{2,} \\. )+ (?: arpa | com | org | net | edu | gov | mil | int | [a-z]{2} | aero | biz | coop | info | museum | name | pro | example | invalid | localhost | test | local | onion | swift ) ) | (?: [0-9]{1,3} \\. [0-9]{1,3} \\. [0-9]{1,3} \\. [0-9]{1,3} ) ) ) )/Dx", $string, -1, PREG_SPLIT_DELIM_CAPTURE); if (count($output) > 1) { $is_a_url = false; foreach ($output as $index => $token) { if ($is_a_url) { if (preg_match("/^[a-zA-Z0-9._-]{2,}@/", $token)) { $url = "mailto:" . $token; } else if (preg_match("/^(https?:|ftp:)\\/*([^\\/&?#]+)\\/*(.*)\$/", $token, $matches)) { $url = $matches[1] . '/' . '/' . $matches[2] . "/" . $matches[3]; } else { preg_match("/^([^\\/&?#]+)\\/*(.*)\$/", $token, $matches); $url = "http:/" . "/" . $matches[1] . "/" . $matches[2]; } $params = @parse_url($url); if (!is_array($params)) $params = Array(); $params['url'] = $url; $params['link'] = $url; $params['text'] = $token; $output[$index] = $this->FillTemplate($this->url_pattern, $params); } $is_a_url = !$is_a_url; } } return $output; }
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.