ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/err.pl
Revision: 1.4
Committed: Fri Nov 30 06:20:43 2001 UTC (22 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.3: +4 -5 lines
Log Message:
*** empty log message ***

File Contents

# Content
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 $id = $self->{remote_id};
97 my $ctime = $HTTP_NOW;
98 my $etime = time2str $conn::blocked{$ip} = $::NOW + $::BLOCKTIME;
99
100 Coro::Event::do_timer(after => 20*rand);
101
102 $self->err(401, "too many connections",
103 {
104 "Content-Type" => "text/html",
105 "Retry-After" => $::BLOCKTIME,
106 "Warning" => "Please do NOT retry, you have been blocked. Press Cancel instead.",
107 "WWW-Authenticate" => "Basic realm=\"Please do NOT retry, you have been blocked. Press Cancel instead.\"",
108 "Connection" => "close",
109 },
110 <<EOF);
111 <html>
112 <head>
113 <title>Too many connections</title>
114 </head>
115 <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000">
116
117 <p>You have been blocked because you didn't behave. You may retry at</p>
118
119 <p><blockquote>$etime.</blockquote></p>
120
121 <p>For your reference, the current time and your identifier is:</p>
122
123 <p><blockquote>$ctime | $id</blockquote></p>
124
125 <p>Until then, each access will renew the block. This should give
126 you ample time to look at the <a href="http://www.goof.com/pcg/marc/animefaq.html#blocked">FAQ</a>.</p>
127
128 </body></html>
129 EOF
130 }
131
132 sub conn::err_segmented_download {
133 my $self = shift;
134 $self->err(400, "segmented downloads are not allowed",
135 { "Content-Type" => "text/html", Connection => "close" }, <<EOF);
136 <html>
137 <head>
138 <title>Segmented downloads are not allowed</title>
139 </head>
140 <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000">
141
142 <p>Segmented downloads are not allowed on this server. Please refer to the
143 <a href="http://www.goof.com/pcg/marc/animefaq.html#segmented_downloads">FAQ</a>.</p>
144
145 </body></html>
146 EOF
147 }
148
149 1;
150