cbparser update

okay, I got a bit carried away with the anti-spammer thing. not the concept, just the code. we only need one variable..

effin_casinos = true;

which you can set to false just before calling bb2html(); if you need to do a "mock" preview, or in any situation where the user has already authorised themselves, i.e. a blog or bulletin board. in this case, cbparser will leave the links unaltered.1

I'll set it to false by default; simply pass effin_casinos = true; just before calling the bb2html() function whenever you need casino-spammer protection. my comments engine (which Istill haven't gotten around to releasing) does it like this..

if (isset($_POST['comment_preview'])) {
    $effin_casinos = false; // only for the preview 
} else {
    $effin_casinos = true; // when they post.. hahah! 
}
$comment = bb2html($_POST['comment'],$name);

This "fix" is in the regular download version, help yourself.

While I was in about the bbcode parser with my spanners and what-not, I added a rudimentarytag balance checking routine. unbalanced tags can really mess up your pages. usually it's unintentional.

if the user's bbcode (or html) tags aren't balanced, cbparser will now returnfalse (same as an empty string (''). you can check for this in your calling script and produce a message telling the user to check their bbcode, or whatever, pretty neat. this..

$comment = bb2html($_POST['comment'],$name);
if ($comment != '') {
    do something funky here;
} else {
    // the user's form will still contain their post
   $unbalanced_tags = true; // I'll use this later
   $comment = "tags don't balance!"; // put in preview area 
}
gives you an idea. the balance checking routine should cover most situations, but is probably not foolproof. I'll chuck this version in the beta section for a spell anyway, just to be sure.

That'll be cbparser v0.5.10b, then.

;o)

references:

1:
in other words, unlike my last blog, Ididn'thave to editthese links by hand!


 ©  2024 « autoconfig.corz.org » 24.12.17  

Welcome to autoconfig.corz.org!

I'm always messing around with the back-end.. See a bug? Wait a minute and try again. Still see a bug? Mail Me!