mdsms etc.
[MyWeb.git] / Web.pm
diff --git a/Web.pm b/Web.pm
index 202ecd9..a317dd3 100644 (file)
--- a/Web.pm
+++ b/Web.pm
@@ -286,7 +286,7 @@ sub a_href ($;$%)
 {
 my($url,$contents,%args)=@_;
 
-       do { $$_=1 if !defined $$_; } for ($args{"size"});
+       do { $$_=1 if !defined $$_; } for (\$args{"size"});
        $contents=CGI::escapeHTML($url) if !defined $contents;
 
        my $r='<a href="';
@@ -300,9 +300,9 @@ my($url,$contents,%args)=@_;
        elsif ($W->{"have_ent"})        # ent client
                { $r.=$urlent; }
        else    # unknown client, &CGI::escapeHTML should not be needed here
-               { $r.=CGI::escapeHTML("http://".$W->{"r"}->hostname()."/Redirect.pl?location=".uri_escape($url)); }
+               { $r.=CGI::escapeHTML($W->{"top_dir"}."/Redirect.pl?location=".uri_escape($url)); }
        $r.='">'.$contents.'</a>';
-       if ($args{"size"} && url_is_local($url) && $url=~/[.](?:gz|rpm|zip|deb)/) {     # Downloadable?
+       if ($args{"size"} && url_is_local($url) && $url=~/[.](?:gz|Z|rpm|zip|deb|lha)/) {       # Downloadable?
                if (!-r $url)
                        { cluck "File not readable: $url"; }
                else {
@@ -319,14 +319,13 @@ sub remote_ip ()
        # As 'Apache::ForwardedFor' takes the first of $ENV{"HTTP_X_FORWARDED_FOR"}
        # while the contents is '127.0.0.1, 213.220.195.171' if client has its own proxy.
        # We must take the last item ourselves.
-       my $r=$ENV{"HTTP_X_FORWARDED_FOR"} || $W->{"r"}->remote_host();
+       my $r=$ENV{"HTTP_X_FORWARDED_FOR"} || $W->{"r"}->get_remote_host();
        $r=~s/^.*,\s*//;
        return $r;
 }
 
 sub is_cz ()
 {
-print STDERR "IP=".remote_ip()."\n";
        return "CZ" eq Geo::IP->new()->country_code_by_addr(remote_ip());
 }
 
@@ -373,8 +372,8 @@ my($file_base)=@_;
                my $file=$file_base.".".$var->{"id"};
                # TODO: Somehow quickly check dependencies?
                system 'make >&2 -s --no-print-directory'
-                                               .' -C '."'".File::Basename::dirname($file)."' '".File::Basename::basename($file)."'";
-#                              if !-f $file;
+                                               .' -C '."'".File::Basename::dirname($file)."' '".File::Basename::basename($file)."'"
+                               if !-f $file;
                push @nego_variants,negotiate_variant(
                                %$var,
                                "size"=>(stat $file)[7],