ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/err.pl
Revision: 1.1
Committed: Sun Aug 26 14:55:46 2001 UTC (22 years, 10 months ago) by root
Content type: text/plain
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 use HTTP::Date;
2    
3     use Coro::Event;
4    
5     sub conn::err_block_country {
6     my $self = shift;
7     my $whois = shift;
8    
9     $whois =~ s/&/&/g;
10     $whois =~ s/</&lt;/g;
11     $self->err(403, "forbidden", { "Content-Type" => "text/html", Connection => "close" }, <<EOF);
12     <html>
13     <head>
14     <title>This material is licensed in your country!</title>
15     </head>
16     <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000">
17    
18     <h1>This material is licensed in your country!</h1>
19    
20     <p>My research has shown that your IP address
21     (<b>$self->{remote_addr}</b>) most probably is located in this country:
22     <b>$self->{country}</b> (ISO-3166-2 code, XX == unknown). The full record is:</p>
23    
24     <pre>
25     $whois
26     </pre>
27    
28     <p>My database says that the material you are trying to access is licensed
29     in your country. If I would distribute these files to your country I would
30     actively <em>hurt</em> the industry behind it, which includes the artists
31     and authors of these videos/mangas. So I hope you understand that I try to
32     avoid this.</p>
33    
34     <p>Please see the <a href="http://www.goof.com/pcg/marc/animefaq.html#licensed">FAQ</a>
35     for a more thorough explanation.</p>
36    
37     <p>If you <em>really</em> think that this is wrong, i.e. the
38     material you tried to access is <em>not</em> licensed in your
39     country or your ip address was misdetected, you can write to <a
40     href="mailto:licensed\@plan9.de">licensed\@plan9.de</a>. Please explain
41     what happened and why you think this is wrong in as much detail as
42     possible.</p>
43    
44     <div align="right">Thanks a lot for understanding.</div>
45    
46     </body>
47     </html>
48     EOF
49     }
50    
51     sub conn::err_block_referer {
52     my $self = shift;
53    
54     my $uri = $self->{uri};
55     $uri =~ s/\/[^\/]+$/\//;
56    
57     $self->slog(6, "REFERER($self->{uri},$self->{h}{referer})");
58    
59     $whois =~ s/&/&amp;/g;
60     $whois =~ s/</&lt;/g;
61     $self->err(203, "non-authoritative", { "Content-Type" => "text/html" }, <<EOF);
62     <html>
63     <head>
64     <title>Unallowed Referral</title>
65     </head>
66     <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000">
67    
68     <h1>The site which referred you has done something bad!</h1>
69    
70     <p>It seems that you are coming from this URL:</p>
71    
72     <pre>$self->{h}{referer}</pre>
73    
74     <p>This site has been blocked, either because it required you to pay
75     money, forced you to click on banners, claimed these files were theirs
76     or something very similar. Please note that you can download these files
77     <em>without</em> having to pay, <em>without</em> clicking banners or jump
78     through other hoops.</p>
79    
80     <p><b>Sites like the one you came from actively hurt the distribution of
81     these files and the service quality for you since I can't move or correct
82     files and you will likely not be able to see the full archive.</b></p>
83    
84     <p>Having that this, you can find the original content (if it is still
85     there) by <b>following <a href="$uri">this link</a>.</b></p>
86    
87     <div align="right">Thanks a lot for understanding.</div>
88    
89     </body>
90     </html>
91     EOF
92     }
93    
94     sub conn::err_blocked {
95     my $self = shift;
96     my $ip = $self->{remote_addr};
97     my $time = time2str $conn::blocked{$ip} = $::NOW + $::BLOCKTIME;
98    
99     Coro::Event::do_timer(after => 20*rand);
100    
101     $self->err(401, "too many connections",
102     {
103     "Content-Type" => "text/html",
104     "Retry-After" => $::BLOCKTIME,
105     "Warning" => "Please do NOT retry, you have been blocked",
106     "WWW-Authenticate" => "Basic realm=\"Please do NOT retry, you have been blocked\"",
107     "Connection" => "close",
108     },
109     <<EOF);
110     <html>
111     <head>
112     <title>Too many connections</title>
113     </head>
114     <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000">
115    
116     <p>You have been blocked because you opened too many connections. You
117     may retry at</p>
118    
119     <p><blockquote>$time.</blockquote></p>
120    
121     <p>Until then, each new access will renew the block. You might want to have a
122     look at the <a href="http://www.goof.com/pcg/marc/animefaq.html#connectionlimit">FAQ</a>.</p>
123    
124     </body></html>
125     EOF
126     }
127    
128     sub conn::err_segmented_download {
129     my $self = shift;
130     $self->err(400, "segmented downloads are not allowed",
131     { "Content-Type" => "text/html", Connection => "close" }, <<EOF);
132     <html>
133     <head>
134     <title>Segmented downloads are not allowed</title>
135     </head>
136     <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000">
137    
138     <p>Segmented downloads are not allowed on this server. Please refer to the
139     <a href="http://www.goof.com/pcg/marc/animefaq.html#segmented_downloads">FAQ</a>.</p>
140    
141     </body></html>
142     EOF
143     }
144    
145     1;
146