Bravo List
Register
Go Back   > Bravo List > Source Code > Active Trackers > xBTiT
Reply
  #1  
Old 13th February 2021, 23:06
JohnHasher's Avatar
JohnHasher JohnHasher is offline
Senior Member
 
Join Date: Apr 2020
Posts: 24
Question tinymce bbcode
TinyMCE bbcode plugin.js :

PHP Code:
/**
 * Copyright (c) Tiny Technologies, Inc. All rights reserved.
 * Licensed under the LGPL or a commercial license.
 * For LGPL see License.txt in the project root for license information.
 * For commercial licenses see https://www.tiny.cloud/
 *
 * Version: 5.4.1 (2020-07-08)
 *
 * FParadise Customs - DO NOT TRY!
 */
!function(){"use strict";var o=tinymce.util.Tools.resolve("tinymce.PluginManager"),e=tinymce.util.Tools.resolve("tinymce.util.Tools"),t=function(t){t=e.trim(t);var o=function(o,e){t=t.replace(o,e)};return o(/\n/gi,"<br />"),o(/\[b\]/gi,"<strong>"),o(/\[\/b\]/gi,"</strong>"),o(/\[i\]/gi,"<em>"),o(/\[\/i\]/gi,"</em>"),o(/\[u\]/gi,"<u>"),o(/\[hr\]/gi,"<hr />"),o(/\[\/u\]/gi,"</u>"),o(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,'<a href="$1">$2</a>'),o(/\[url\](.*?)\[\/url\]/gi,'<a href="$1">$1</a>'),o(/\[img\](.*?)\[\/img\]/gi,'<img src="$1" />'),o(/\[color=(.*?)\](.*?)\[\/color\]/gi,'<font color="$1">$2</font>'),o(/\[bg-color=(.*?)\](.*?)\[\/bg-color\]/gi,'<span style="background-color: $1;">$2</span>'),o(/\[(right|left|center|justify)\](.*?)\[\/(right|left|center|justify)\]/gi,'<p style="text-align: $1;">$2</p>'),o(/\[list=disc\](.*?)\[\/list\]/gi,'<ul>$1</ul>'),o(/\[list=1\](.*?)\[\/list\]/gi,'<ol>$1</ol>'),o(/\[indent=(.*?)px\](.*?)\[\/indent\]/gi,'<p style="padding-left: $1px;">$2</p>'),o(/\[li\](.*?)\[\/li\]/gi,'<li>$1</li>'),o(/\[size=(.*?)\](.*?)\[\/size\]/gi,'<span style="font-size:$1;">$2</span>'),o(/\[align=(left|right)\] \[video=(.*?)\] \[\/align\]/gi,'<video style="float: $1;" width="500" height="410"><source src="$2"></video>'),o(/\[align=center\] \[video=(.*?)\] \[\/align\]/gi,'<video style="display: block; margin-left: auto; margin-right: auto;" width="500" height="410"><source src="$1"></video>'),o(/\[video=(.*?)\]/gi,'<video width="500" height="410"><source src="$1"></video>'),o(/\[code\](.*?)\[\/code\]/gi,'<span class="codeStyle">$1</span>&nbsp;'),o(/\<<<@!1!@>>>"),o(/<font.*?class="codeStyle".*?color="(.*?)".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),o(/<font.*?class="quoteStyle".*?color="(.*?)".*?>(.*?)<\/font>/gi,"<<<@!2!@>>>"),o(/<span style="color: ?(.*?);">(.*?)<\/span>/gi,"[color=$1]$2[/color]"),o(/<h(1|2|3|4|5|6)>(.*?)<\/h(1|2|3|4|5|6)>/gi,"[size=$1]$2[/size]"),o(/<p style="text-align: (right|left|center|justify);">(.*?)<\/p>/gi,"[$1] $[/$1]"),o(/<hr \/>/gi,"[hr]"),o(/<font.*?color="(.*?)".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]"),o(/<ul>(.*?)<\/ul>/gi,"[list=disc]$1[/list]"),o(/<ul style="text-align: (center|right|left|justify);">(.*?)<\/ul>/gi,"[$1][list=disc]$2[/list][/$1]"),o(/<ol>(.*?)<\/ol>/gi,"[list=1]$1[/list]"),o(/<span style="font-size: (8pt|10pt|12pt|14pt|18pt|24pt|36pt); background-color: (.*?);">(.*?)<\/span>/gi,"[size=$1][bg-color=$2]$3[/bg-color][/size]"),o(/<span style="font-size: (8pt|10pt|12pt|14pt|18pt|24pt|36pt); color: (.*?);">(.*?)<\/span>/gi,"[size=$1][color=$2]$3[/color][/size]"),o(/<ul><li style="list-style-typenone;">(.*?)<\/li><\/ul>/gi,"$1"),o(/<li style="list-style-typenone;">(.*?)<\/li>/gi,"$1"),o(/<span style="font-size: (8pt|10pt|12pt|14pt|18pt|24pt|36pt);">(.*?)<\/span>/gi,"[size=$1]$2[/size]"),o(/<video width="500" height="410"><source src="(.*?)"><\/video>/gi,"[video=$1]"),o(/<video style="displayblockmargin-leftautomargin-rightauto;" width="500" height="410"><source src="(.*?)"><\/video>/gi,"[align=center] [video=$1] [/align]"),o(/<p style="text-alignjustify;"><video width="500" height="410"><source src="(.*?)"><\/video><\/p>/gi,"[align=left] [video=$2] [/align]"),o(/<video style="float: (right|left);" width="500" height="410"><source src="(.*?)"><\/video>/gi,"[align=$1] [video=$2] [/align]"),o(/<font>(.*?)<\/font>/gi,"$1"),o(/<img src="(.*?)".*?\/>/gi,"[img]$1[/img]"),o(/<img style="float: (right|left|center);" src="(.*?)".*?\/>/gi,"[$1][img]$2[/img][/$1]"),o(/<img style="displayblockmargin-leftautomargin-rightauto;" src="(.*?)".*?\/>/gi,"[center][img]$1[/img][/center]"),o(/<p style="padding-left: (.*?)pxtext-align: (center|left|right|justify);">(.*?)<\/p>/gi,"[$2][indent=$1px]$3[/indent][/$2]"),o(/<span class="codeStyle">(.*?)<\/span>/gi,"[code]$1[/code]"),o(/<li>(.*?)<\/li>/gi,"[li]$1[/li]"),o(/<li style="text-align: (center|right|left|justify);">(.*?)<\/li>/gi,"[li]$2[/li]"),o(/<p style="padding-left: (.*?)px;">(.*?)<\/p>/gi,"[indent=$1px]$2[/indent]"),o(/<span class="quoteStyle">(.*?)<\/span>/gi,"<<<@!3!@>>>"),o(/<strong class="codeStyle">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]"),o(/<strong class="quoteStyle">(.*?)<\/strong>/gi,"<<<@!4!@>>>"),o(/<em class="codeStyle">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]"),o(/<span style="background-color: (.*?);">(.*?)<\/span>/gi,"[bg-color=$1]$2[/bg-color]"),o(/<em class="quoteStyle">(.*?)<\/em>/gi,"<<<@!5!@>>>"),o(/<u class="codeStyle">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]"),o(/<u class="quoteStyle">(.*?)<\/u>/gi,"<<<@!6!@>>>"),o(/<\/(strong|b)>/gi,"[/b]"),o(/<(strong|b)>/gi,"[b]"),o(/<\/(em|i)>/gi,"[/i]"),o(/<(em|i)>/gi,"[i]"),o(/<\/u>/gi,"[/u]"),o(/<span style="text-decoration: ?underline;">(.*?)<\/span>/gi,"[u]$1[/u]"),o(/<u>/gi,"[u]"),o(/<blockquote[^>]*>/gi,"<<<@!7!@>>>"),o(/<br \/>/gi,"\n"),o(/<br\/>/gi,"\n"),o(/<br>/gi,"\n"),o(/<p>/gi,""),o(/<\/p>/gi,"\n"),o(/&nbsp;|\u00a0/gi," "),o(/&quot;/gi,'"'),o(/&lt;/gi,"<"),o(/&gt;/gi,">"),o(/&amp;/gi,"&"),t}(o.content))})})}()}(); 
edited bbcode :
Code:
$img_count=0;
// 3 functions for the bbcode. Have to be declared outside the function to be able to call bbcode more than once.
function dosize($matches) {
  return '<span style="font-size: '.(50*$matches[3]).'%">'.$matches[4].'</span>';
}

function noparsed($matches) { // any character that is parsed, must be here
  static $replace=array(
    '://' => '://',
    '('   => '(',
    ')'   => ')',
    '-'   => '-',
    '/'   => '/',
    ':'   => ':',
    '['   => '[',
    ']'   => ']',
    '_'   => '_',);
  return str_replace( array_keys($replace), array_values($replace) ,$matches[2]);
}

function formatlist($matches) {
  if ($matches[3]=='') {
    $content.='<ul>';
    $end='</ul>';
  } elseif(strtolower($matches[3])=="a" || strtolower($matches[3])=="i") {
    $content.="<ol type=\"{$matches[3]}\">";
    $end='</ol>';
  }
  elseif (strtolower($matches[3])=="1") {
    $content.="<ol>";
    $end='</ol>';
  } else {
    $content.="<ul type=\"{$matches[3]}\">";
    $end='</ul>';
  }

  return $content.$matches[4].$end;
}

function parseimage($matches) {
  global $img_count;

  $img_count++;
  return "<div id=\"img{$img_count}\" style=\"font-size:'1'; display:inline;\"><a href=\"$matches[3]://$matches[4]\" data-fancybox=\"images\" ><img name=\"img{$img_count}\" onload='resize(this);' src='$matches[3]://$matches[4]' border='0' alt='' /></a></div>";
}

function bbcode($content) {
  global $language;
  // Fix & to be &amp; unless it's already &amp; or a special character like  ▀  or some regualr ones like <,>,",(c), . More can be found here: http://www.utexas.edu/learn/html/spchar.html  But they can use the decimal verisons if the want those
  $content=preg_replace('/&(?!(amp|[#0-9]+|lt|gt|quot|copy|nbsp);)/ix','&amp;',$content);

  // But some special chars are bad, at least according to vB, so strip them. Most are just blank characters used to bypass filters, except for ‮ which is just awesome!
  $content=str_replace(array(' ','','‍','‌','‭','‮'),'',$content);

  // Change new lines to <br />. nl2br function probably would work also. It's probably the same as this though. And gets rid of htmlchars. htmlentities screws up the &amp; stuff.
  $content=str_replace(array('<','>','\'','"',"\r\n","\r","\n"),array('&lt;','&gt;',''','&quot;','<br />','<br />','<br />'),$content);


  do{ // No parse. Just replace anything that is parsed, into their HTML equivalents
    $content=preg_replace_callback('/\[(noparse(?:\d|))\](.+?)\[\/\1\]/i','noparsed',$content, -1, $count);
  }while($count);

  do{ // code tags must be parsed first, because their contents are not parsed.
    $content=preg_replace('/\[(code(?:\d|))\](.+?)\[\/\1\]/i','<br /><b>Code</b><br /><table width="100%" border="1" cellspacing="0" cellpadding="10" class="code"><tr><td>[tt][noparse9]$2[/noparse9][/tt]</td></tr></table><br />',$content, -1, $count);
  }while($count);
          //[align=(center|left|right|justify)]text[/align]
    $content = preg_replace("/\[align=([a-zA-Z]+)\](.+?)\[\/align\]/is","<div style=\"text-align:\\1\">\\2</div>", $content);
    $content = preg_replace("/\[indent=([0-9]+)px\](.+?)\[\/indent\]/is","<p style=\"padding-left: \\1px;\">\\2</p>", $content);

// Video tag [video=url]
// YouTube Vids
$content = preg_replace("/\[video=[^\s'\"<>]*youtube.com.*v=([^\s'\"<>]+)\]/ims", "<object width=\"500\" height=\"410\"><param name=\"movie\" value=\"http://www.youtube.com/v/\\1\"></param><embed src=\"http://www.youtube.com/v/\\1\" type=\"application/x-shockwave-flash\" width=\"500\" height=\"410\"></embed></object>", $content);
$content = preg_replace("/\[video=[^\s'\"<>]*youtu.be.*\/([^\s'\"<>]+)\]/ims", "<object width=\"500\" height=\"410\"><param name=\"movie\" value=\"http://www.youtube.com/v/\\1\"></param><embed src=\"http://www.youtube.com/v/\\1\" type=\"application/x-shockwave-flash\" width=\"500\" height=\"410\"></embed></object>", $content);
// Google Vids
//$content = preg_replace("/\[video=[^\s'\"<>]*video.google.com.*docid=(-?[0-9]+).*\]/ims", "<embed style=\"width:500px; height:410px;\" id=\"VideoPlayback\" align=\"middle\" type=\"application/x-shockwave-flash\" src=\"http://video.google.com/googleplayer.swf?docId=\\1\" allowScriptAccess=\"sameDomain\" quality=\"best\" bgcolor=\"#ffffff\" scale=\"noScale\" wmode=\"window\" salign=\"TL\"  FlashVars=\"playerMode=embedded\"> </embed>", $content);

     //[video=http://somesite.com/test.swf]
//        "<param name=movie value=\\1/><embed width=470 height=350 src=\\1></embed>", $content);

  do{ // code blocks insert the noparse tag. Can't parse the code block first, or you can't use noparse on it.
    $content=preg_replace_callback('/\[(noparse(?:\d|))\](.+?)\[\/\1\]/i','noparsed',$content, -1, $count);
  }while($count);

  // Quotes!
  do{
    $content = preg_replace('/\[(quote(?:\d|))\](.+?)\[\/\1\]/i','<br /><b>'.$language['QUOTE'].':</b><br /><table width="100%" border="1" cellspacing="0" cellpadding="10" class="quote"><tr><td >$2</td></tr></table><br />',$content, -1, $count);
  }while($count);
  do{
    $content = preg_replace('/\[(quote(?:\d|))=(&quot;|&#(?:0|)39;|"|\'|)(.+?)\2\](.+?)\[\/\1\]/i','<br /><b>$3 '.$language['WROTE'].':</b><br /><table width="100%" border="1" cellspacing="0" cellpadding="10" class="quote"><tr><td>$4</td></tr></table><br />',$content, -1, $count);
  }while($count);
  // .userquoteinfo { font-size:85%; font-weight: bold; font-style: italic; }

  // Images. They have to have http://. src attributes are XSSable in IE 6.0, Netscape, and Opera. http://ha.ckers.org/xss.html. Even though it's hard to do without () or \, best not to mess around with it.
  $content=preg_replace_callback('/\[(img(?:\d|))\](&quot;|&#(?:0|)39;|"|\'|)(http|https|ftp|ftps):\/\/([a-z0-9\/\-\+\?\&\.\=\_\~\#\'\%\;]*)\2\[\/\1\]/i','parseimage',$content);
  $content=preg_replace_callback('/\[(img(?:\d|))=(&quot;|&#(?:0|)39;|"|\'|)(http|https|ftp|ftps):\/\/([a-z0-9\/\-\+\?\&\.\=\_\~\#\'\%\;]*)\2\]/i','parseimage',$content);

  // text
  $content=preg_replace('/\[(url(?:\d|))\=(&quot;|&#(?:0|)39;|"|\'|)(http|https|ftp|ftps|ed2k|irc):\/\/([a-z0-9\/\-\+\?\&\.\=\_\~\#\'\%\;]*)\2\](.+?)\[\/\1\]/i', '<a href="$3://$4" target="_blank">$5</a>', $content);
  // For people too lazy to put http:// on the uri. /Shouldn't/ be XSSable
  $content=preg_replace('/\[(url(?:\d|))\=(&quot;|&#(?:0|)39;|"|\'|)([a-z0-9\/\-\+\?\&\.\=\_\~\#\'\%\;]*)\2\](.+?)\[\/\1\]/i', '<a href="http://$3" target="_blank">$4</a>', $content);

  // uri
  $content=preg_replace('/\[(url(?:\d|))\](http|https|ftp|ftps|ed2k|irc):\/\/([a-z0-9\/\-\+\?\&\.\=\_\~\#\'\%\;]*)\[\/\1\]/i','<a href="$2://$3" target="_blank">$2://$3</a>',$content);
  // lazy http:// people...
  $content=preg_replace('/\[(url(?:\d|))\]([a-z0-9\/\-\+\?\&\.\=\_\~\#\'\%\;]*)\[\/\1\]/i','<a href="http://$2" target="_blank">http://$2</a>',$content);

  // http://www.google.com -> <a href="http://www.google.com">http://www.google.com</a>
  $content=preg_replace('/(?<![href|src]=[&quot;|&#(?:0|)39;|"|\'])(http|https|ftp|ftps|ed2k|irc):\/\/([a-z0-9\/\-\+\?\&\.\=\_\~\#\'\%\;]*)/i','<a href="$1://$2" target="_blank">$1://$2</a>',$content);

  // Email. Do people even use this? Yes, so they can get revenge on someone by posting their email address.
  $content=preg_replace('/\[(email(?:\d|))\]([a-z0-9\/\-\+\?\&\.\=\_\~\#\'\%\;]+)@([a-z0-9\/\-\+\?\&\.\=\_\~\#\'\%\;]+)\[\/\1\]/i','<a href="mailto:$2@$3">$2@$3</a>',$content);

//[Spoiler]TEXT[/Spoiler]
    $content=preg_replace("/\[Spoiler\]((\s|.)+?)\[\/Spoiler\]/", "<div style="padding: 3px;  border: 1px solid #d8d8d8; font-size: 1em;"><div style="text-transform: uppercase; border-bottom: 1px solid #CCCCCC; margin-bottom: 3px; font-size: 0.8em; font-weight: bold; display: block;"><span onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerHTML = '<b>Spoiler: </b><a href=\'#\' onClick=\'return false;\'>hide</a>'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerHTML = '<b>Spoiler: </b><a href=\'#\' onClick=\'return false;\'>show</a>'; }" /><b>Spoiler:</b><a href="#" onClick="return false;">show</a></span></div><div class="quotecontent"><div style="display: none;">\\1</div></div></div>",$content);

// [marquee]Marquee[/marquee]
    $content=preg_replace("/\[scroll=([a-zA-Z ,]+)\]((\s|.)+?)\[\/scroll\]/i","<marquee class="tableb" direction="\\1" scrollamount="3" scrolldelay="2" onmouseover="this.stop();" onmouseout="this.start();">\\2</marquee>",$content);

  do{ // bold, big, italics, strike through, tt, underline, em, strong, subscript, superscript, overline, pre
    $content=preg_replace('/\[((none|b|big|i|s|strike|tt|u|o|underline|em|strong|sub|sup|pre)(?:\d|))\](.+?)\[\/\1\]/i','<$2>$3</$2>',$content, -1, $count);
  }while($count);

  do{ // [left], [center], [right] and [justify] tags
    $content=preg_replace('/\[((left|right|center|justify)(?:\d|))\](.+?)\[\/\1\]/i', '<div align="$2">$3</div>',$content, -1, $count);
  }while($count);

  do{ // the color is the tag itself, like [fgyellow]yellow text[/fgyellow], or [fg-blue]blue text[/fg-blue]
  // If the color is the tag itself, like [green], then it must ALWAYS be a whitelist of accepted colors.
    $content=preg_replace('/\[((?:fg|fg-|)(black|silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|aqua)(?:\d|))\](.+?)\[\/\1\]/i','<font color="$2">$3</font>',$content, -1, $count);
  }while($count);
  do{ // font color. Word type, like RED not limited in name, for backwards compatability.
    $content=preg_replace('/\[((?:fg|fg-|)colo(?:u|)r(?:\d|))=(&quot;|&#(?:0|)39;|"|\'|)([a-z]{0,25})\2\](.+?)\[\/\1\]/i','<font color="$3">$4</font>',$content, -1, $count);
  }
/*  while($count);
  do{ // Color specified in RGB triplet, like GREY
    $content=preg_replace('/\[((?:fg|fg-|)colo(?:u|)r(?:\d|))=(&quot;|#|&#(?:0|)39;|"|\'|)([\dA-F]{0,9})\2\](.+?)\[\/\1\]/i','<span style="color:#$3;">$4</span>',$content, -1, $count);
  } */
  while($count);
  do{ // Color specified in RGB triplet, like GREY
    $content=preg_replace('/\[color=(.+?)](.+?)\[\/color]/i','<span style="color:$1;">$2</span>',$content, -1, $count);
  }
  while($count);

  // background colors
  do{ // background color specified in RGB triplet, like [bg-color=ff0000]red background[/bg-color]
    $content=preg_replace('/\[bg-color=(.+?)](.+?)\[\/bg-color]/i','<span style="background: $1;">$2</span>',$content, -1, $count);
  }while($count);
  do{ // but since the bgcolor tag is new, I will limit the colors, for maximum web compatability. Of course you can set any color you like with the RGB background tag. Maybe remove color whitelist, dependong on user feedback.
    $content=preg_replace('/\[((?:bg|bg-)colo(?:u|)r(?:\d|))=(&quot;|&#(?:0|)39;|"|\'|)(black|silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|aqua)\2\](.+?)\[\/\1\]/i','<span style="background: $3;">$4</span>',$content, -1, $count);
  }while($count);
  do{ // This background tag uses the following syntax, for a red background: [bgred] or [bg-red]
    $content=preg_replace('/\[((?:bg|bg-)(black|silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|aqua)(?:\d|))\](.+?)\[\/\1\]/i','<span style="background: $2;">$3</span>',$content, -1, $count);
  }while($count);
  do{ // background color specified in RGB triplet, like [bg-color=ff0000]red background[/bg-color]
    $content=preg_replace('/\[((?:bg|bg-)colo(?:u|)r(?:\d|))=(&quot;|&#(?:0|)39;|"|\'|)([0-9A-F]{3,6})\2\](.+?)\[\/\1\]/i','<span style="background: #$3;">$4</span>',$content, -1, $count);
  }while($count);

//font-family
    $content=preg_replace('/\[font=([a-zA-Z ,]+)\]((\s|.)+?)\[\/font\]/i', '<span style="font-family:\'\1\'">$2</span>',$content);

  do{ // Size. 1,2,3,4...8 = 50%, 100%, 150%, 200%...400%  Algo: 50 * size
    $content = preg_replace_callback('/\[(size(?:\d|))=(&quot;|&#(?:0|)39;|"|\'|)([1-8])\2\](.+?)\[\/\1\]/i','dosize',$content, -1, $count);
  }while($count);
  do{ // Size. 1,2,3,4...8 = 50%, 100%, 150%, 200%...400%  Algo: 50 * size
    $content = preg_replace('/\[size=(8pt|10pt|12pt|14pt|18pt|24pt|36pt)](.+?)\[\/size]/i','<span style="font-size: $1;">$2</span>',$content, -1, $count);
  }while($count);
  do{ // [size=xx-small] style tag
    $content = preg_replace('/\[(size(?:\d|))=(&quot;|&#(?:0|)39;|"|\'|)((xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller)(?:\d|))\2\](.+?)\[\/\1\]/i','<font style="font-size: $4;">$5</font>',$content, -1, $count);
  }while($count);
  do{ // [xx-large] style tag
    $content = preg_replace('/\[((xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller)(?:\d|))\](.+?)\[\/\1\]/i','<font style="font-size: $2;">$3</font>',$content, -1, $count);
  }while($count);

  //Lists
  do{ // [list] or [list=a] or [list=circle] etc
    $content=preg_replace_callback('/\[(list(?:\d|))(?:=(&quot;|&#(?:0|)39;|"|\'|)(a|i|1|disc|square|circle)\2|)\](.+?)\[\/\1\]/i','formatlist',$content, -1, $count);
  }while($count);

  // just some little things I thought might be nice to have.
  static $replace=array(
    "  "   => " &nbsp;",
    "[*]"  => "<li>",
    "[li]"  => "<li>",
    "[/li]" => "</li>",
    "[hr]" => "<hr>",
    "[br]" => "<br />",
    "(c)"  => "&copy;",
    "[c]"  => "&copy;",
    "(p)"  => "℗",
    "[p]"  => "℗",
    "(r)"  => "&reg;",
    "[r]"  => "&reg;",
    "(tm)" => "&trade;",
    "[tm]" => "&trade;",
    "1/2"  => "&frac12;",
    "1/3"  => "⅓",
    "2/3"  => "⅔",
    "1/4"  => "&frac14",
    "3/4"  => "&frac34;",
    "1/5"  => "⅕",
    "2/5"  => "⅖",
    "3/5"  => "⅗",
    "4/5"  => "⅘",
    "1/6"  => "⅙",
    "5/6"  => "⅚",
    "1/8"  => "⅛",
    "3/8"  => "⅜",
    "5/8"  => "⅝",
    "7/8"  => "⅞"
  );
  $content=str_ireplace(array_keys($replace), array_values($replace) ,$content);



  return $content;
}

function dehtml($content) {
  $content=preg_replace('/&(?!(amp|[#0-9]+|lt|gt|quot|copy|nbsp);)/ix','&amp;',$content);
  $content=str_replace(array(' ','','‍','‌','‭','‮'),'',$content);
  return str_replace(array('<','>','\'','"'),array('&lt;','&gt;',''','&quot;'),$content);
}

unable to parse smiley / errors occuring when using list


if i use another editor , i need to redo all bbcodes
Reply With Quote
  #2  
Old 14th February 2021, 12:46
budgie's Avatar
budgie budgie is offline
Senior Member
 
Join Date: Nov 2020
Posts: 22
Default
first of you need to fix this line
its backing on this so u get error page
// Change new lines to <br />. nl2br function probably would work also. It's probably the same as this though. And gets rid of htmlchars. htmlentities screws up the &amp; stuff.
Code:
$content=str_replace(array(' ','','‍','‌','‭','‮// Change new lines to <br />. nl2br function probably would work also. It's probably the same as this though. And gets rid of 
htmlchars. htmlentities screws up the &amp; stuff.'),'',$content);

Last edited by budgie; 14th February 2021 at 13:10.
Reply With Quote
  #3  
Old 20th February 2021, 17:12
JohnHasher's Avatar
JohnHasher JohnHasher is offline
Senior Member
 
Join Date: Apr 2020
Posts: 24
Post
PHP Code:
function dehtml($content) {
  
$content=preg_replace('/&(?!(amp|[#0-9]+|lt|gt|quot|copy|nbsp);)/ix','&amp;',$content);
  
$content=str_replace(array(' ','','‍','‌','‭','‮'),'',$content);
  return 
str_replace(array('<','>','\'','"'),array('&lt;','&gt;',''','&quot;'),$content);


the code is getting filtered by bvlist editor , here is the function.


by the way parse is working for now except for the emotes / smilies (i think the unicodes are getting filtered.)

Bump: that line is getting filtered :(

Bump: line is getting filtered :(
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 06:56. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2021, vBulletin Solutions Inc.