[pmwiki-users] Solved: Commentbox - Preventing posting of directives

Patrick R. Michaud pmichaud at pobox.com
Mon Oct 2 16:29:18 CDT 2006


On Mon, Oct 02, 2006 at 04:21:09PM -0500, Patrick R. Michaud wrote:
> On Mon, Oct 02, 2006 at 11:06:09PM +0200, Mike wrote:
> >    if anybody is interested: I added a line to the commentboxplus recipe
> >    which introduces a global variable $PreventDirectives.
> >
> >        SDV($PreventDirectives,0);
> >        if($PreventDirectives == 1){   
> >            $_POST['text'] = ereg_replace(":",":",$_POST['text']);
> >        }
> 
> This actually replaces all colons (including those in "http:" links), 
> whereas I would only replace colons that follow a parenthesis:
> 
>     if ($PreventDirectives) {
>       $_POST['text'] = preg_replace('/\\(:/', '(:', $_POST['text']);
>     }

Also, by convention anything in PmWiki that is an "on/off"
switch is named "$Enable....", so this should be:

    if ($EnablePreventDirectives) { 
      ....

And you can avoid the SDV by using the IsEnabled() function:

    if (IsEnabled($EnabledPreventDirectives, 0)) {
      ...

The "0" here means "default to zero if not set".
 
Pm




More information about the pmwiki-users mailing list