'Geo::IP' dependency is now optional.
[MyWeb.git] / Web.pm
diff --git a/Web.pm b/Web.pm
index 5c7348e..2c720f3 100644 (file)
--- a/Web.pm
+++ b/Web.pm
@@ -69,8 +69,9 @@ use Carp qw(cluck confess);
 use URI::Escape;
 require HTTP::BrowserDetect;
 require HTTP::Negotiate;
-require Geo::IP;
+my $have_Geo_IP; BEGIN { $have_Geo_IP=eval { require Geo::IP; 1; }; }
 require CGI;
+require Apache2;
 
 
 # Undo 'www/engine/httpd-restart' as it may use obsolete Perl for 'mod_perl'
@@ -183,6 +184,8 @@ my($in)=@_;
 
        if (my $uri=$ENV{"REQUEST_URI"}) {
                if ($W->{"args"}{"Wabs"}) {
+                       # FIXME: $in may not be defined here!
+                       # to prevent: Use of uninitialized value in ...
                        if ($in=~m#^/#) {
                                $in=~s#^/*##;
                                }
@@ -409,7 +412,7 @@ my($url,$contents,%args)=@_;
        $r.='"';
        do { $r.=" $_" if $_; } for ($args{"attr"});
        $r.='>'.$contents.'</a>';
-       if ($args{"size"} && url_is_local($url) && $url=~/[.](?:gz|Z|rpm|zip|deb|lha)/) {       # Downloadable?
+       if ($args{"size"} && url_is_local($url) && ($args{"size"}>=2 || $url=~/[.](?:gz|Z|rpm|zip|deb|lha)/)) { # Downloadable?
                $url=top_dir_disk().$url if $url=~m#^/#;
                if (!-r $url)
                        { cluck "File not readable: $url"; }
@@ -434,6 +437,7 @@ sub remote_ip ()
 
 sub is_cz ()
 {
+       return 0 if !$have_Geo_IP;
        return "CZ" eq Geo::IP->new()->country_code_by_addr(remote_ip());
 }