Volg de onderstaande video om te zien hoe je onze site als web-app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
Niet mee eens, als je dit toepast laat je toe dat iemand enkel <b> post & zodoende heel uw site in 't vet zet, om van een gigantische link nog maar te zwijgen.killgore zei:regex is overpower in dit geval
str_replace will do the trick.
zoiets dus:PHP:$search = array("[b]","[/b]"); $replace= array("<b>","</b>"); $txt = str_replace($search,$replace,$txt);
<?php
$Tags =
'~'.
'(?:'.
'\[(([^\s=]+)(?:(?: |=).+?)?)(?<!/)\]'.
'('.
'(?s).+?'.
')'.
'\[/\2\]'.
')'.
'|'.
'(?:'.
'(?m)'.
'\[(([^\s=]+)(?:(?: |=).+?)?) /\]'.
'(.+?)'.
'$'.
')'.
'~'.
'i'.
'S'
;
$Args =
'~'.
'([^\s=]+)'.
'(?:'.
'='.
'(?(?=\')'.
'\'(.+?)\''.
'|'.
'(.+?)'.
')'.
')?'.
'(?: |$)'.
'~'
;
function ubb_parser($Tekst){
Global $Tags;
$Tekst = htmlspecialchars($Tekst);
$Tekst = preg_replace("#(^|[ \n\r\t])www.([a-z\-0-9]+).([a-z]{2,4})($|[ \n\r\t])#i", "\\1<a href=\"http://www.\\2.\\3\" target=\"_blank\">www.\\2.\\3</a>\\4", $Tekst);
$Tekst = preg_replace("#(^|[ \n\r\t])(((ftp://)|(http://)|(https://))([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+))#i", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $Tekst);
$Tekst = preg_replace("#(^|[ \n\r\t])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", "\\1<a href='mailto:\\2@\\3'>\\2@\\3</a>", $Tekst);
while (preg_match($Tags, $Tekst)) {
$Tekst = preg_replace_callback($Tags, '_ubbTag', $Tekst);
}
return nl2br($Tekst);
}
function _ubbTag($matches){
$len = count($matches);
if($len === 4){
$tag = strtolower($matches[2]);
$args = _ubbArgs($matches[1], $tag);
$content = $matches[3];
}
elseif($len === 7){
$tag = strtolower($matches[5]);
$args = _ubbArgs($matches[4], $tag);
$content = $matches[6];
}
if(function_exists('ubbTag_'.$tag)) {
return call_user_func_array("ubbTag_".$tag, array($content, $args));
}
else{
return call_user_func_array("ubbTag", array($content));
}
}
function _ubbArgs($args_raw, $tag){
Global $Args;
preg_match_all($Args, $args_raw, $matches, PREG_SET_ORDER);
$args = array();
foreach ($matches as $match) {
if(isset($match[3])){
$match[2] = $match[3];
}
if(!isset($match[2]) && $match[1] == $tag) {
continue;
}
$args[trim(strtolower($match[1]))] = isset($match[2]) ? trim($match[2]) : true;
}
return $args;
}
function ubbTag($content){
return $content;
}
?>
<?php
function ubbTag_i($content){
return '<i>'.$content.'</i>';
}
function ubbTag_b($content){
return '<b>'.$content.'</b>';
}
function ubbTag_u($content){
return '<u>'.$content.'</u>';
}
function ubbTag_s($content){
return '<s>'.$content.'</s>';
}
function ubbTag_sub($content){
return '<sub>'.$content.'</sub>';
}
function ubbTag_sup($content){
return '<sup>'.$content.'</sup>';
}
function ubbTag_li($content){
return '<li>'.$content.'</li>';
}
function ubbTag_line($content){
return '<hr />'.$content;
}
function ubbTag_quote($content, $args){
$args = array_merge(array('quote' => 'Quote'), $args);
extract($args);
return '<blockquote><b><i>'.$quote.':</i></b>'.
'<div class="ubb_quote">'.
$content.
'</div>'.
'</blockquote>';
}
function ubbTag_offtopic($content){
return '<blockquote><b><i>Offtopic:</i></b>'.
'<div class="ubb_offtopic">'.
$content.
'</div>'.
'</blockquote>';
}
function ubbTag_email($content, $args){
$args = array_merge(array('title' => 'mailto'), $args);
extract($args);
return "<a href = 'mailto:".$content."' title = '".$title."'>".$content."</a>";
}
function ubbTag_url($content, $args){
$args = array_merge(array('url' => NULL, 'title' => NULL, 'target' => NULL), $args);
extract($args);
if(is_null($url)){
$url = $content;
}
if(is_null($title)){
$title = $url;
}
if(is_null($target)){
$target = "_self";
}
return "<a href = '".htmlspecialchars($url)."' target = '".$target."' title = '".htmlspecialchars($title)."'>".htmlspecialchars($content)."</a>";
}
function ubbTag_code($content, $args){
$args = array_merge(array('name' => 'code'), $args);
extract($args);
$trans_table = array_flip(get_html_translation_table(HTML_ENTITIES));
$content = strtr($content, $trans_table);
ob_start();
$code = highlight_string(trim($content));
$code = ob_get_contents();
ob_end_clean();
$count = substr_count($code, '<br />') + 1;
for ($nrs='', $i=1; $i<=$count; $nrs.=$i.'<br />', $i++) {}
return '<div class="codeContainer">'.
'<div class="codeHead">'.$name.':</div>'.
'<div class="codeNr">'.$nrs.'</div>'.
'<div class="codeBlock">'.$code.'</div>'.
'<div class="codeFoot"> </div>'.
'</div>';
}
function ubbTag_img($content, $args){
$args = array_merge(array('alt' => 'picture', 'width' => false, 'height' => false, 'border' => 0), $args);
extract($args);
if(!is_numeric($width)){
$width = false;
}
if(!is_numeric($height)){
$height = false;
}
if(!is_numeric($border)){
$border= false;
}
return "<img src = '".htmlspecialchars($content)."' alt = '".htmlspecialchars($alt)."' style = '".
($width !== false ? "width:".$width."px;" : "").
($height !== false ? "height:".$height."px;" : "").
($border !== false ? "border:".$border.";" : "")."' />";
}
?>
met url's moet je zowiezo regexes toepassenRadiance zei:Niet mee eens, als je dit toepast laat je toe dat iemand enkel <b> post & zodoende heel uw site in 't vet zet, om van een gigantische link nog maar te zwijgen.
.
.