AUBBC
view release on metacpan or search on metacpan
's' = ' '
'-' = '-'
':' = ':'
'_' = '_'
type - 1 is style [name://pattern], 2 is style [name]pattern[/name], 3 is style [name],
the next setting for type the function will not be used to run Perl subroutines and
will replace the text with what text is defined in the function setting, the setting is
type 4 this will use style [name] but will work different then the other built settings
see function below on how type 4 works
function - a pre-defined subroutine that receives the matched pattern, tag name and returns what you want,
unless type is set to 4 then it will replace the tag with what text is in the function.
Note: if the function returns undefined, '' or 0 the tag will not be changed.
level - the array number of the security level
error - the text or HTML to show if user has no access
Note: For the build tags leaving the variables blank will default level to 0 and
error to the $AUBBC::BAD_MESSAGE string.
Usage:
package My_Message;
use AUBBC;
my $aubbc = AUBBC->new();
$aubbc->add_build_tag(
name => 'ok',
pattern => 'l,s',
type => 1,
function => 'My_Message::check_ok_tag',
);
$aubbc->add_build_tag(
name => 'ip',
pattern => '',
type => 3,
function => 'My_Message::get_some_tag',
);
$aubbc->add_build_tag(
name => 'agent',
pattern => '',
type => 3,
function => 'My_Message::get_some_tag',
);
$aubbc->add_build_tag(
name => 'hello',
pattern => '',
type => 4,
function => 'Hello World!',
);
my $message = '[ok://test me] [ok://test other] [ok://n0 w00rk] [ip] [agent] [hello]';
$message = $aubbc->do_all_ubbc($message);
print $message;
sub check_ok_tag {
my ($tag_name, $text_from_AUBBC) = @_;
if ($text_from_AUBBC eq 'test me') {
return 'Works Good 1';
}
else {
return 'Works Good 2';
}
}
sub get_some_tag {
my ($tag_name, $text_from_AUBBC) = @_;
$tag_name = lc($tag_name);
$text_from_AUBBC = $ENV{'REMOTE_ADDR'} if ($tag_name eq 'ip');
$text_from_AUBBC = $aubbc->script_escape($ENV{'HTTP_USER_AGENT'}) if ($tag_name eq 'agent');
return $text_from_AUBBC;
}
1;
=head2 $aubbc->remove_build_tag($name, $option);
There are two ways to use this.
1) Remove a single built tag: $aubbc->remove_build_tag($name);
2) Remove all built tags: $aubbc->remove_build_tag('', 1);
=head1 Error Message
=head2 $AUBBC::BAD_MESSAGE
Default message is 'Unathorized', this message is used when the code finds bad characters in [email] or [img] tags.
Usage of this setting:
use AUBBC;
$AUBBC::BAD_MESSAGE = 'Unauthorized use of characters or pattern in this tag.';
# est...
=head2 $aubbc->aubbc_error();
There are two errors for add_build_tag that would die if the wrong input was given
when adding a build tag. The error message will now be stored in this method during
the instance and any new tag that had an error will not be processed.
Since there is only two errors for add_build_tag you can check this method after
all new tags have been added. All errors stack in this method and are seperaited
by a \n newline.
Usage:
$aubbc->aubbc_error('Insert Your Error'); # Add an error
print $aubbc->aubbc_error();
die $aubbc->aubbc_error() if $aubbc->aubbc_error();
=head1 Memoize
This setting can turn AUBBC's usage of Memoize on or off.
=head2 $AUBBC::MEMOIZE
Default setting 1 will check if it needs to load Memoize, if loaded then load the sub's that need the speed.
Setting 0 will not use Memoize.
Usage of this setting:
use Memoize;
( run in 1.149 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )