&img ¢erimg &rightimg
$W
&input_hidden_persistents
+ &escapeHTML
);
our @ISA=qw(Tie::Handle Exporter);
return OK;
}
+sub W_check(;$)
+{
+my($self)=@_;
+
+ # Use &eval to prevent: Global $r object is not available. Set:\n\tPerlOptions +GlobalRequest\nin ...
+ # CGI requires valid "r": check it beforehand here.
+ confess "Calling sensitive dynamic code from a static code" if !eval { Apache2::RequestUtil->request(); };
+ confess "Calling sensitive dynamic code without My::Web::init" if !$W->{"__PACKAGE__"};
+}
+
sub init ($%)
{
my($class,%args)=@_;
$W->{"head"}.='<script type="text/javascript" src="'.path_web('/have_js.pm').'"></script>'."\n";
}
- do { args_check(%$_) if $_; } for ($W->{"args_check"});
+ do { _args_check(%$_) if $_; } for ($W->{"args_check"});
return bless $W,$class;
}
{
my($text)=@_;
- # Use &eval to prevent: Global $r object is not available. Set:\n\tPerlOptions +GlobalRequest\nin ...
- # CGI requires valid "r": check it beforehand here.
- confess "Calling dynamic URL generator from a static code" if !eval { Apache2::RequestUtil->request(); };
# Prevent &CGI::escapeHTML breaking utf-8 strings like: \xC4\x9B eq \x{11B}
do { cluck "charset==$_" if $_ && $_ ne "utf-8"; } for CGI::charset();
CGI::charset("utf-8");
sub fatal (;$);
-sub args_check (%)
+sub _args_check (%)
{
my(%tmpl)=@_;
my($uri)=@_;
cluck if !ref $uri;
+ W_check();
my $urient=escapeHTML($uri);
return $uri if $uri eq $urient;
return $urient if uri_is_local $uri;
{
my($in,$contents,%args)=@_;
+ W_check();
do { $$_=1 if !defined $$_; } for (\$args{"size"});
if (!defined $contents) {
$contents=$in;
sub input_hidden_persistents()
{
+ W_check();
return join("",map({
my $key=$_;
my $val=$W->{"args"}{$key};
{
my($in,$alt,%args)=@_;
+ W_check();
my($path_web,$path_abs_disk)=_img_src($in,%args);
my($width,$height)=Image::Size::imgsize($path_abs_disk);
$alt=~s/<[^>]*>//g;