ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/err.pl
Revision: 1.2
Committed: Sun Sep 2 02:27:51 2001 UTC (22 years, 10 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.1: +10 -5 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     my $ip = $self->{remote_addr};
97 root 1.2 my $ctime = $HTTP_NOW;
98     my $etime = time2str $conn::blocked{$ip} = $::NOW + $::BLOCKTIME;
99 root 1.1
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 root 1.2 "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 root 1.1 "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 opened too many connections. You
118     may retry at</p>
119    
120 root 1.2 <p><blockquote>$etime.</blockquote></p>
121    
122     <p>For your reference, the current time is:</p>
123    
124     <p><blockquote>$ctime.</blockquote></p>
125 root 1.1
126     <p>Until then, each new access will renew the block. You might want to have a
127 root 1.2 look at the <a href="http://www.goof.com/pcg/marc/animefaq.html#blocked">FAQ</a>.</p>
128 root 1.1
129     </body></html>
130     EOF
131     }
132    
133     sub conn::err_segmented_download {
134     my $self = shift;
135     $self->err(400, "segmented downloads are not allowed",
136     { "Content-Type" => "text/html", Connection => "close" }, <<EOF);
137     <html>
138     <head>
139     <title>Segmented downloads are not allowed</title>
140     </head>
141     <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000">
142    
143     <p>Segmented downloads are not allowed on this server. Please refer to the
144     <a href="http://www.goof.com/pcg/marc/animefaq.html#segmented_downloads">FAQ</a>.</p>
145    
146     </body></html>
147     EOF
148     }
149    
150     1;
151