Просмотр файла sys/fnc/links.php

Размер файла: 1.19Kb
  1. <?
  2.  
  3. function img_preg($arr)
  4. {
  5. return '<img src="http://'.$_SERVER['HTTP_HOST'].'/go.php?go='.base64_encode(html_entity_decode($arr[1])).'" alt="img" />';
  6. }
  7.  
  8. function links_preg1($arr)
  9. {
  10. global $set;
  11.  
  12. if (ereg('^http://'.$_SERVER['HTTP_HOST'],$arr[1]) || !ereg('://',$arr[1]))
  13. return '<a href="'.$arr[1].'">'.$arr[2].'</a>';
  14. else
  15. return '<a'.($set['web']?' target="_blank"':null).' href="http://'.$_SERVER['HTTP_HOST'].'/go.php?go='.base64_encode(html_entity_decode($arr[1])).'">'.$arr[2].'</a>';
  16.  
  17. }
  18. function links_preg2($arr)
  19. {
  20. global $set;
  21. if (ereg('^http://'.$_SERVER['HTTP_HOST'],$arr[2]))
  22. return $arr[1].'<a href="'.$arr[2].'">'.$arr[2].'</a>'.$arr[4];
  23. else
  24. return $arr[1].'<a'.($set['web']?' target="_blank"':null).' href="http://'.$_SERVER['HTTP_HOST'].'/go.php?go='.base64_encode(html_entity_decode($arr[2])).'">'.$arr[2].'</a>'.$arr[4];
  25. }
  26. function links($msg)
  27. {
  28. global $set;
  29. if ($set['bb_img'])$msg=preg_replace_callback('/\[img\](.+)\[\/img\]/isU', 'img_preg', $msg);
  30. if ($set['bb_url'])$msg=preg_replace_callback('/\[url=(.+)\](.+)\[\/url\]/isU', 'links_preg1', $msg);
  31. if ($set['bb_http'])$msg=preg_replace_callback('~(^|\s)([a-z]+://([^ \r\n\t`\'"]+))(\s|$)~iu', 'links_preg2', $msg);
  32. return $msg;
  33. }
  34.  
  35. ?>