static function handle_img($params, $contents) { $origAppend = ''; # are only specific images allowed? if (isset(TagHandler::$tagconfig['i']['img']['allowedimgs'])) { if (!isset(TagHandler::$tagconfig['i']['img']['allowedimgs'][$params['params'][0]])) { return TagHandler::handle_empty($params, $contents); } else { $origAppend = $contents; $contents = TagHandler::$tagconfig['i']['img']['allowedimgs'][$params['params'][0]]; } # if } # if return array('prepend' => '<img src="' . $contents . '">', 'content' => $origAppend, 'append' => ''); }
function setdeniedtags($deniedtags) { TagHandler::$deniedtags = $deniedtags; } // setdeniedtags
function formatDescription($tmp) { # initialize ubb parser $parser = new UbbParse($tmp); TagHandler::setDeniedTags(array()); $tmp = $parser->parse(); $tmp = $tmp[0]; # en replace eventuele misvormde br tags $tmp = str_ireplace('<br>', '<br>', $tmp); $tmp = str_ireplace('<br />', '<br>', $tmp); $tmp = str_ireplace('&lt;br />', '<br>', $tmp); return $tmp; }
function formatContent($tmp) { # escape alle embedded HTML, maar eerst zetten we de spot inhoud om naar # volledige HTML, dit doen we omdat er soms embedded entities (í e.d.) # in zitten welke we wel willen behouden. $tmp = htmlentities($tmp, ENT_QUOTES, 'UTF-8'); $tmp = html_entity_decode($tmp, ENT_COMPAT, 'UTF-8'); # Code gecopieerd vanaf # http://stackoverflow.com/questions/635844/php-how-to-grab-an-url-out-of-a-chunk-of-text # converteert linkjes naar bb code $pattern = "((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\\w\\d:#@%/;\$()~_?\\+-=\\\\.&]*)"; $tmp = preg_replace($pattern, '[url=\\0]\\0[/url]', $tmp); # initialize ubb parser $parser = new SpotUbb_parser($tmp); TagHandler::setDeniedTags(array()); TagHandler::setadditionalinfo('img', 'allowedimgs', $this->getSmileyList()); $tmp = $parser->parse(); $tmp = $tmp[0]; # en replace eventuele misvormde br tags $tmp = str_ireplace('<br>', '<br />', $tmp); $tmp = str_ireplace('<br />', '<br />', $tmp); $tmp = str_ireplace('&lt;br />', '<br />', $tmp); return $tmp; }
/** * Returns the formatted UBB */ function converttoubb($parseresult, $allowedchildren = Array(null)) { $output = Array(''); $bodycount = 0; $parseResultCount = sizeof($parseresult); for($i = 0; $i < $parseResultCount; $i++) { /* save the current allowedchildren */ $saveallowedchildren = $allowedchildren; /* first get the tag results */ if ($parseresult[$i]['tagname'] !== '') { $tagresult = NULL; /* Get the configuration for this tag, as it also includes the function * to call when processing this tag */ $tagconfig = TagHandler::gettagconfig($parseresult[$i]['tagname']); /* Are we allowed to run this tag? */ if (($allowedchildren[0] === NULL) | (array_search($parseresult[$i]['tagname'], $allowedchildren))) { $tagresult = TagHandler::process_tag($parseresult[$i]['tagname'], $parseresult[$i]['params'], $parseresult[$i]['content']); } // if /* If tag result was NULL, the given tag is invalid, so reconstruct it */ if ($tagresult === NULL) { if ($tagconfig['closetags'] !== Array(NULL)) { $appendclosetag = '[/' . $parseresult[$i]['tagname'] . ']'; } else { $appendclosetag = ''; } // else /* add the tag back in */ $tagresult = Array('prepend' => '[' . $parseresult[$i]['tagname'] . $parseresult[$i]['params']['originalparams'] . ']', 'append' => $appendclosetag ); } else { /* allow the tags to overwrite the content */ $parseresult[$i]['content'] = $tagresult['content']; } // else /* Now append the allowed children */ if ($tagconfig['allowedchildren'][0] === '') { /* deny all child tags */ $allowedchildren = Array(''); } else if ($tagconfig['allowedchildren'][0] !== NULL) { /* all tags are allowed */ $allowedchildren = array_intersect($allowedchildren, $tagconfig['allowedchildren']); } // else } else { $tagresult = Array('prepend' => '', 'append' => ''); } // else $output[$bodycount] .= $tagresult['prepend']; if (is_array($parseresult[$i]['content'])) { $parsedchildcontent = $this->converttoubb($parseresult[$i]['content'], $allowedchildren); $output[$bodycount] .= $parsedchildcontent[0]; if (count($parsedchildcontent) > 1) { array_shift($parsedchildcontent); $output = array_merge($output, $parsedchildcontent); } // if } else { $output[$bodycount] .= $parseresult[$i]['content']; } // else $output[$bodycount] .= $tagresult['append']; /* restore the saved allowed children */ $allowedchildren = $saveallowedchildren; } // for return $output; } // converttoubb
function formatContent($tmp) { # Make sure specific HTML is converted $tmp = htmlentities($tmp, ENT_QUOTES, 'UTF-8'); # Code gecopieerd vanaf # http://stackoverflow.com/questions/635844/php-how-to-grab-an-url-out-of-a-chunk-of-text # converteert linkjes naar bb code $pattern = "(([^=])((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\\w\\d:#@%/;\$()~_?\\+-=\\\\.&]*))"; $tmp = preg_replace($pattern, '\\1[url=\\2]\\2[/url]', $tmp); # initialize ubb parser $parser = new SpotUbb_parser($tmp); TagHandler::setDeniedTags(array()); TagHandler::setadditionalinfo('img', 'allowedimgs', $this->getSmileyList()); $tmp = $parser->parse(); $tmp = $tmp[0]; # en replace eventuele misvormde br tags $tmp = str_ireplace('<br>', '<br />', $tmp); $tmp = str_ireplace('<br />', '<br />', $tmp); $tmp = str_ireplace('&lt;br />', '<br />', $tmp); return $tmp; }
function formatContent($tmp) { # escape alle embedded HTML, maar eerst zetten we de spot inhoud om naar # volledige HTML, dit doen we omdat er soms embedded entities (í e.d.) # in zitten welke we wel willen behouden. $tmp = htmlentities($tmp); $tmp = html_entity_decode($tmp, ENT_COMPAT, 'UTF-8'); # Code gecopieerd vanaf # http://codesnippets.joyent.com/posts/show/2104 # converteert linkjes naar bb code $pattern = "@\b(https?://)?(([0-9a-zA-Z_!~*'().&=+$%-]+:)?[0-9a-zA-Z_!~*'().&=+$%-]+\@)" . "?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\.)*([0-9a-zA-Z][0-9a-zA-Z-]" . "{0,61})?[0-9a-zA-Z]\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\@&=+$,%#-]+)*/?)@"; $tmp = preg_replace($pattern, '[url=\0]\0[/url]', $tmp); # initialize ubb parser $parser = new SpotUbb_parser($tmp); TagHandler::setDeniedTags( Array() ); TagHandler::setadditionalinfo('img', 'allowedimgs', $this->getSmileyList() ); $tmp = $parser->parse(); $tmp = $tmp[0]; # en replace eventuele misvormde br tags $tmp = str_ireplace('<br>', '<br />', $tmp); $tmp = str_ireplace('<br />', '<br />', $tmp); $tmp = str_ireplace('&lt;br />', '<br />', $tmp); return $tmp; } # formatContent