SHARE
TWEET

urlparser

canhnm Apr 7th, 2012 34 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $str = 'Mời tham gia câu lạc bộ Những người ưa thích nghề quảng cáo
  3.  
  4. Các bạn click vào link này để tham gia nhé: http://cafecongso.com/room/discuss/Hoi-quang-cao-69.html';
  5.  
  6. define('PROXYURL', 'http://cafecongso.com/proxy?url=');
  7. function urlParser($str){
  8.     $str  = str_replace("\\r","\r",$str);
  9.     $str  = str_replace("\\n","\n<BR>",$str);
  10.     $str  = str_replace("\\n\\r","\n\r",$str);
  11.  
  12.     $in=array(
  13.       '`((?:https?|ftp)://\S+[[:alnum:]]/?)`si',
  14.       '`((?<!//)(www\.\S+[[:alnum:]]/?))`si'
  15.     );
  16.     $out=array(
  17.       '<a href="'.PROXYURL.'$1">$1</a> ',
  18.       '<a href="'.PROXYURL.'http://$proxyUrl$1">$1</a>'
  19.     );
  20.     return preg_replace($in,$out,$str);
  21. }
  22.  
  23. echo urlParser($str);
  24.  
  25. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top