/** * Handles a [url] tag. Creates a link to another web page. * * @param string If tag has option, the displayable name. Else, the URL. * @param string If tag has option, the URL. * @param bool If this is for an image, just return the link * * @return string HTML representation of the tag. */ function handle_bbcode_url($text, $link, $image = false) { $rightlink = trim($link); if (empty($rightlink)) { // no option -- use param $rightlink = trim($text); } $rightlink = str_replace(array('`', '"', "'", '['), array('`', '"', ''', '['), $this->stripSmilies($rightlink)); // remove double spaces -- fixes issues with wordwrap $rightlink = str_replace(' ', '', $rightlink); if (!preg_match('#^[a-z0-9]+(?<!about|javascript|vbscript|data):#si', $rightlink)) { $rightlink = "http://{$rightlink}"; } if (!trim($link) or str_replace(' ', '', $text) == $rightlink) { $tmp = vB5_String::unHtmlSpecialChars($rightlink); if (vB_String::vbStrlen($tmp) > 55 and $this->isWysiwyg() == false) { $text = vB5_String::htmlSpecialCharsUni(vB5_String::vbChop($tmp, 36) . '...' . substr($tmp, -14)); } else { // under the 55 chars length, don't wordwrap this $text = str_replace(' ', '', $text); } } static $current_url, $current_host, $allowed, $friendlyurls = array(); if (!isset($current_url)) { $current_url = @vB5_String::parseUrl(self::$bbUrl); } $is_external = self::$urlNoFollow; if (self::$urlNoFollow) { if (!isset($current_host)) { $current_host = preg_replace('#:(\\d)+$#', '', self::$vBHttpHost); $allowed = preg_split('#\\s+#', self::$urlNoFollowWhiteList, -1, PREG_SPLIT_NO_EMPTY); $allowed[] = preg_replace('#^www\\.#i', '', $current_host); $allowed[] = preg_replace('#^www\\.#i', '', $current_url['host']); } $target_url = preg_replace('#^([a-z0-9]+:(//)?)#', '', $rightlink); foreach ($allowed as $host) { if (vB5_String::stripos($target_url, $host) !== false) { $is_external = false; } } } if ($image) { return array('link' => $rightlink, 'nofollow' => $is_external); } // standard URL hyperlink return "<a href=\"{$rightlink}\" target=\"_blank\"" . ($is_external ? ' rel="nofollow"' : '') . ">{$text}</a>"; }