ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/err.pl
Revision: 1.6
Committed: Mon Dec 3 21:32:35 2001 UTC (22 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.5: +1 -0 lines
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 root 1.4 my $id = $self->{remote_id};
97 root 1.5 my $block = $conn::blocked{$id};
98    
99     $block->[2]++;
100    
101     if ($block->[0] < $::NOW + $::BLOCKTIME) {
102     $block->[0] = $::NOW + $::BLOCKTIME;
103     }
104    
105     my $status = 403;
106     my $hdr = {
107     "Content-Type" => "text/html",
108     "Retry-After" => $block->[0] - $::NOW,
109     "Connection" => "close",
110     };
111    
112 root 1.2 my $ctime = $HTTP_NOW;
113 root 1.5 my $etime = time2str $block->[0];
114    
115     my $limit = $block->[3];
116     $block->[3] = $::NOW + 10;
117 root 1.1
118 root 1.5 if ($limit > $::NOW) {
119     Coro::Event::do_timer(after => $limit - $::NOW);
120 root 1.1
121 root 1.5 if ($block->[2] > 30) {
122 root 1.6 $block->[3] = $::NOW + 180;
123 root 1.5 $status = 401;
124     $hdr->{Warning} = "Please do NOT retry, you have been blocked. Press Cancel instead.";
125     $hdr->{"WWW-Authenticate"} = "Basic realm=\"Please do NOT retry, you have been blocked. Press Cancel instead.\"";
126     }
127     }
128    
129     $self->err($status, $block->[1], $hdr,
130 root 1.1 <<EOF);
131     <html>
132     <head>
133 root 1.5 <title>$block->[1]</title>
134 root 1.1 </head>
135     <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000">
136    
137 root 1.5 <p>You have been blocked because you didn't behave. The exact reason was:</p>
138    
139     <h1><blockquote>"$block->[1]"</blockquote></h1>
140    
141     <p>You may retry not earlier than:</p>
142 root 1.1
143 root 1.2 <p><blockquote>$etime.</blockquote></p>
144    
145 root 1.5 <p>Until then, each access will renew the block. This should give
146     you ample time to look at the <a href="http://www.goof.com/pcg/marc/animefaq.html#blocked">FAQ</a>.</p>
147    
148     <p>For your reference, the current time and your connection ID is:</p>
149 root 1.2
150 root 1.3 <p><blockquote>$ctime | $id</blockquote></p>
151 root 1.1
152     </body></html>
153     EOF
154     }
155    
156     sub conn::err_segmented_download {
157     my $self = shift;
158     $self->err(400, "segmented downloads are not allowed",
159     { "Content-Type" => "text/html", Connection => "close" }, <<EOF);
160     <html>
161     <head>
162     <title>Segmented downloads are not allowed</title>
163     </head>
164     <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000">
165    
166     <p>Segmented downloads are not allowed on this server. Please refer to the
167     <a href="http://www.goof.com/pcg/marc/animefaq.html#segmented_downloads">FAQ</a>.</p>
168    
169     </body></html>
170     EOF
171     }
172    
173     1;
174