Bjork

Untitled

Nov 12th, 2017
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.96 KB | None | 0 0
  1. function bbcode_format($str){
  2.     // Parse BB code
  3.         $simple_search = array(
  4.                                 '/\[b\](.*?)\[\/b\]/is',
  5.                                 '/\[i\](.*?)\[\/i\]/is',
  6.                                 '/\[u\](.*?)\[\/u\]/is',
  7.                                 '/\[s\](.*?)\[\/s\]/is',
  8.                                 '/\[quote\](.*?)\[\/quote\]/is',
  9.                                 '/\[link\=(.*?)\](.*?)\[\/link\]/is',
  10.                                 '/\[url\=(.*?)\](.*?)\[\/url\]/is',
  11.                                 '/\[color\=(.*?)\](.*?)\[\/color\]/is',
  12.                                 '/\[size=small\](.*?)\[\/size\]/is',
  13.                                 '/\[size=large\](.*?)\[\/size\]/is',
  14.                                 '/\[code\](.*?)\[\/code\]/is',
  15.                                 '/\[habbo\=(.*?)\](.*?)\[\/habbo\]/is',
  16.                                 '/\[room\=(.*?)\](.*?)\[\/room\]/is',
  17.                                 '/\[group\=(.*?)\](.*?)\[\/group\]/is',
  18.                                 '/\[img\](.*?)\[\/img\]/is',
  19.                                 '/\[spoil\](.*?)\[\/spoil\]/is',
  20.                                 '/\[yt\](.*?)\[\/yt\]/is'
  21.                                 );
  22.         $simple_replace = array(
  23.                                 '<strong>$1</strong>',
  24.                                 '<em>$1</em>',
  25.                                 '<u>$1</u>',
  26.                                 '<s>$1</s>',
  27.                                 "<div class='bbcode-quote'>$1</div>",
  28.                                 "<a href='$1' target='_blank'>$2</a>",
  29.                                 "<a href='$1' target='_blank'>$2</a>",
  30.                                 "<font color='$1'>$2</font>",
  31.                                 "<font size='1'>$1</font>",
  32.                                 "<font size='3'>$1</font>",
  33.                                 '<pre>$1</pre>',
  34.                                 "<a href='./user_profile.php?id=$1'>$2</a>",
  35.                                 "<a onclick=\"roomForward(this, '$1', 'private'); return false;\" target=\"client\" href=\"./client.php?forwardId=2&roomId=$1\">$2</a>",
  36.                                 "<a href='./group_profile.php?id=$1'>$2</a>",
  37.                                 '<a href="$1" data-lightbox="$1"><img src="$1"/></a>',
  38.                                 "<span style=\"background: none repeat scroll 0% 0% rgb(189, 202, 210); color: rgb(189, 202, 210);\" onmouseover=\"this.style.background='#5b7289'\" onmouseout=\"this.style.background='#bdcad2'\">$1</span>",
  39.                                 '<center><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="520" height="315" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/$1&amp;hl=fr_FR&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="520" height="315" src="http://www.youtube.com/v/$1&amp;hl=fr_FR&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></center>');
  40.         $str = preg_replace ($simple_search, $simple_replace, $str);
  41.         return $str;
  42. }
  43.  
  44. function bbcode_restore($str){
  45.     // Parse BB code
  46.         $simple_search = array(
  47.                                 '/\[b\](.*?)\[\/b\]/is',
  48.                                 '/\[i\](.*?)\[\/i\]/is',
  49.                                 '/\[u\](.*?)\[\/u\]/is',
  50.                                 '/\[s\](.*?)\[\/s\]/is',
  51.                                 '/\[quote\](.*?)\[\/quote\]/is',
  52.                                 '/\[link\=(.*?)\](.*?)\[\/link\]/is',
  53.                                 '/\[url\=(.*?)\](.*?)\[\/url\]/is',
  54.                                 '/\[color\=(.*?)\](.*?)\[\/color\]/is',
  55.                                 '/\[size=small\](.*?)\[\/size\]/is',
  56.                                 '/\[size=large\](.*?)\[\/size\]/is',
  57.                                 '/\[code\](.*?)\[\/code\]/is',
  58.                                 '/\[habbo\=(.*?)\](.*?)\[\/habbo\]/is',
  59.                                 '/\[room\=(.*?)\](.*?)\[\/room\]/is',
  60.                                 '/\[group\=(.*?)\](.*?)\[\/group\]/is',
  61.                 '/\[img\](.*?)\[\/img\]/is',
  62.                 '/\[yt\](.*?)\[\/yt\]/is'
  63.                                 );
  64.         $simple_replace = array(
  65.                                 '<strong>$1</strong>',
  66.                                 '<em>$1</em>',
  67.                                 '<u>$1</u>',
  68.                                 '<s>$1</s>',
  69.                                 "<div class='bbcode-quote'>$1</div>",
  70.                                 "<a href='$1'>$2</a>",
  71.                                 "<a href='$1'>$2</a>",
  72.                                 "<font color='$1'>$2</font>",
  73.                                 "<font size='1'>$1</font>",
  74.                                 "<font size='3'>$1</font>",
  75.                                 '<pre>$1</pre>',
  76.                                 "<a href='./user_profile.php?id=$1'>$2</a>",
  77.                                 "<a onclick=\"roomForward(this, '$1', 'private'); return false;\" target=\"client\" href=\"./client.php?forwardId=2&roomId=$1\">$2</a>",
  78.                                 "<a href='./group_profile.php?id=$1'>$2</a>",
  79.                 '<a href="$1" data-lightbox="$1"><img src="$1"/></a>',
  80.                 '<center><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="520" height="315" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/$1&amp;hl=fr_FR&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="520" height="315" src="http://www.youtube.com/v/$1&amp;hl=fr_FR&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></center>');
  81.         $str = preg_replace ($simple_replace, $simple_search, $str);
  82.         return $str;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment