Beispiel #1
0
 /**
  * Callback for the auto-linker regex.
  *
  * @param array $match
  *
  * @return string
  */
 protected function _autoLinkUrlCallback(array $match)
 {
     $link = XenForo_Helper_String::prepareAutoLinkedUrl($match[0]);
     if ($link['url'] === $link['linkText']) {
         $tag = '[url]' . $link['url'] . '[/url]';
     } else {
         $tag = '[url="' . $link['url'] . '"]' . $link['linkText'] . '[/url]';
     }
     return $tag . $link['suffixText'];
 }
Beispiel #2
0
 /**
  * Handles autolinking the given URL.
  *
  * @param string $url
  *
  * @return string
  */
 protected function _autoLinkUrl($url)
 {
     $link = XenForo_Helper_String::prepareAutoLinkedUrl($url);
     if ($this->_fixProxy && preg_match('/proxy\\.php\\?[a-z0-9_]+=(http[^&]+)&/i', $link['url'], $match)) {
         // proxy link of some sort, adjust to the original one
         $url = urldecode($match[1]);
         if (preg_match('/./u', $url)) {
             if ($link['url'] == $link['linkText']) {
                 $link['linkText'] = $url;
             }
             $link['url'] = $url;
         }
     }
     if ($link['url'] === $link['linkText']) {
         if ($this->_autoEmbed['embedType'] != XenForo_Helper_Media::AUTO_EMBED_MEDIA_DISABLED && $this->_autoEmbedRemaining > 0 && $this->_enableAutoEmbed && ($mediaTag = XenForo_Helper_Media::convertMediaLinkToEmbedHtml($link['url'], $this->_autoEmbed))) {
             $tag = $mediaTag;
             $this->_autoEmbedRemaining--;
         } else {
             $tag = '[url]' . $link['url'] . '[/url]';
         }
     } else {
         $tag = '[url="' . $link['url'] . '"]' . $link['linkText'] . '[/url]';
     }
     return $tag . $link['suffixText'];
 }
Beispiel #3
0
 /**
  * Handles autolinking the given URL.
  *
  * @param string $url
  *
  * @return string
  */
 protected function _autoLinkUrl($url)
 {
     $link = XenForo_Helper_String::prepareAutoLinkedUrl($url);
     if ($this->_fixProxy && preg_match('/proxy\\.php\\?[a-z0-9_]+=(http[^&]+)&/i', $link['url'], $match)) {
         // proxy link of some sort, adjust to the original one
         $url = urldecode($match[1]);
         if (preg_match('/./u', $url)) {
             if ($link['url'] == $link['linkText']) {
                 $link['linkText'] = $url;
             }
             $link['url'] = $url;
         }
     }
     if ($link['url'] === $link['linkText']) {
         if ($this->_autoEmbed['embedType'] != XenForo_Helper_Media::AUTO_EMBED_MEDIA_DISABLED && $this->_autoEmbedRemaining > 0 && $this->_enableAutoEmbed && ($mediaTag = XenForo_Helper_Media::convertMediaLinkToEmbedHtml($link['url'], $this->_autoEmbed))) {
             $tag = $mediaTag;
             $this->_autoEmbedRemaining--;
         } else {
             $urlToPageTitle = XenForo_Application::getOptions()->urlToPageTitle;
             if (!empty($urlToPageTitle['enabled']) && microtime(true) - $this->_startTime < $this->_urlTitleTimeLimit && $link['url'] === XenForo_Helper_String::censorString($link['url'])) {
                 $title = $this->_getUrlTitle($link['url']);
                 if ($title) {
                     $format = $urlToPageTitle['format'];
                     if (!$format) {
                         $format = '{title}';
                     }
                     $tokens = array('{title}' => $title, '{url}' => $link['url']);
                     $linkTitle = strtr($format, $tokens);
                     $tag = '[URL="' . $link['url'] . '"]' . $linkTitle . '[/URL]';
                 } else {
                     $tag = '[URL]' . $link['url'] . '[/URL]';
                 }
                 if ($this->_streamFile) {
                     @unlink($this->_streamFile);
                     $this->_streamFile = null;
                 }
             } else {
                 $tag = '[URL]' . $link['url'] . '[/URL]';
             }
         }
     } else {
         $tag = '[URL="' . $link['url'] . '"]' . $link['linkText'] . '[/URL]';
     }
     return $tag . $link['suffixText'];
 }