Guest User

stox

a guest
Mar 9th, 2009
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. // Make plain text URIs in text into clickable hyperlinks
  2. function autolinks($text) {
  3. global $prefs;
  4. // check to see if autolinks is enabled before calling this function
  5. // if ($prefs['feature_autolinks'] == "y") {
  6. $attrib = '';
  7. if ($prefs['popupLinks'] == 'y')
  8. $attrib .= 'target="_blank" ';
  9. $attrib .= 'rel="nofollow" ';
  10. if ($prefs['feature_wiki_ext_icon'] == 'y') {
  11. $attrib .= 'class="wiki external" ';
  12. $attrib .= 'rel="nofollow" ';
  13. $ext_icon = "<img border=\"0\" class=\"externallink\" src=\"img/icons/external_link.gif\" alt=\" (external link)\" />";
  14. } else {
  15. $attrib .= 'class="wiki" ';
  16. $ext_icon = "";
  17. }
  18.  
  19.  
  20.  
  21.  
  22. // *****
  23. // This section handles external links of the form [url] and such.
  24. // *****
  25.  
  26. $links = $this->get_links($data);
  27. $notcachedlinks = $this->get_links_nocache($data);
  28. $cachedlinks = array_diff($links, $notcachedlinks);
  29. $this->cache_links($cachedlinks);
  30.  
  31. // Note that there're links that are replaced
  32. foreach ($links as $link) {
  33. $target = '';
  34. $class = 'class="wiki"';
  35. $ext_icon = '';
  36. $rel='';
  37.  
  38. if ($prefs['popupLinks'] == 'y') {
  39. $target = 'target="_blank"';
  40. $rel='nofollow';
  41. }
  42.  
  43. if (!isset($_SERVER['SERVER_NAME']) && isset($_SERVER['HTTP_HOST'])) {
  44. $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
  45. }
  46. if (empty($_SERVER['SERVER_NAME']) || strstr($link, $_SERVER["SERVER_NAME"]) || !strstr($link, '://')) {
  47. $target = '';
  48. } else {
  49. $class = 'class="wiki external"';
  50. $rel='nofollow';
  51. if ($prefs['feature_wiki_ext_icon'] == 'y') {
  52. $ext_icon = "<img border=\"0\" class=\"externallink\" src=\"img/icons /external_link.gif\" alt=\" (external link)\" />";
  53. }
  54. $rel='external nofollow';
  55. }
Advertisement
Add Comment
Please, Sign In to add comment