1 | use PApp::SQL; |
1 | use PApp::SQL; |
2 | use Storable (); |
2 | use Storable (); |
3 | |
|
|
4 | sub escape_html { |
|
|
5 | local $_ = shift; |
|
|
6 | s/([()<>%&?,; ='"\x00-\x1f\x80-\xff])/sprintf "%%%02X", ord($1)/ge; |
|
|
7 | $_; |
|
|
8 | } |
|
|
9 | |
3 | |
10 | my $SD_VERSION = 1; |
4 | my $SD_VERSION = 1; |
11 | |
5 | |
12 | my $ignore = qr/ ^(?:robots.txt$|\.) /x; |
6 | my $ignore = qr/ ^(?:robots.txt$|\.) /x; |
13 | |
7 | |
… | |
… | |
19 | my $path = ""; |
13 | my $path = ""; |
20 | my $prefix = ""; |
14 | my $prefix = ""; |
21 | |
15 | |
22 | for ("http://".$self->server_hostport, split /\//, substr $self->{name}, 1) { |
16 | for ("http://".$self->server_hostport, split /\//, substr $self->{name}, 1) { |
23 | next if $_ eq "."; |
17 | next if $_ eq "."; |
24 | $path .= "<a href='".escape_html("$prefix$_")."/'>$_</a> / "; |
18 | $path .= "<a href='".escape_uri("$prefix$_")."/'>$_</a> / "; |
25 | $prefix .= "$_/"; |
19 | $prefix .= "$_/"; |
26 | } |
20 | } |
27 | $data->{path} = $path; |
21 | $data->{path} = $path; |
28 | } |
22 | } |
29 | |
23 | |
… | |
… | |
73 | for (@dirs) { |
67 | for (@dirs) { |
74 | if (++$col >= $cols) { |
68 | if (++$col >= $cols) { |
75 | $stat .= "<tr>"; |
69 | $stat .= "<tr>"; |
76 | $col = 0; |
70 | $col = 0; |
77 | } |
71 | } |
78 | $stat .= "<td><a href='".escape_html($_)."'>$_</a> "; |
72 | $stat .= "<td><a href='".escape_uri($_)."'>$_</a> "; |
79 | } |
73 | } |
80 | $stat .= "</table>"; |
74 | $stat .= "</table>"; |
81 | } |
75 | } |
82 | if (@files) { |
76 | if (@files) { |
83 | $flen = $flen + 1 + $slen + 1 + 3; |
77 | $flen = $flen + 1 + $slen + 1 + 3; |
… | |
… | |
88 | for (@files) { |
82 | for (@files) { |
89 | if (++$col >= $cols) { |
83 | if (++$col >= $cols) { |
90 | $stat .= "<tr>"; |
84 | $stat .= "<tr>"; |
91 | $col = 0; |
85 | $col = 0; |
92 | } |
86 | } |
93 | $stat .= "<td><a href='".escape_html($_->[0])."'>$_->[0]</a><td align='right'>$_->[1]<td> "; |
87 | $stat .= "<td><a href='".escape_uri($_->[0])."'>$_->[0]</a><td align='right'>$_->[1]<td> "; |
94 | } |
88 | } |
95 | $stat .= "</table>"; |
89 | $stat .= "</table>"; |
96 | } |
90 | } |
97 | $data->{stat} = $stat; |
91 | $data->{stat} = $stat; |
98 | } else { |
92 | } else { |
… | |
… | |
179 | </head> |
173 | </head> |
180 | <body text="black" link="#1010C0" vlink="#101080" alink="red" bgcolor="white"> |
174 | <body text="black" link="#1010C0" vlink="#101080" alink="red" bgcolor="white"> |
181 | <large> |
175 | <large> |
182 | This page has moved to $url.<br /> |
176 | This page has moved to $url.<br /> |
183 | <a href="$url"> |
177 | <a href="$url"> |
184 | The automatic redirection has failed. Please try a <i>slightly</i> newer browser next time, and in the meantime <i>please</i> follow this link ;) |
178 | The automatic redirection has failed. Please try a <i>slightly</i> |
|
|
179 | newer browser next time, and in the meantime <i>please</i> follow this link ;) |
185 | </a> |
180 | </a> |
186 | </large> |
181 | </large> |
187 | </body> |
182 | </body> |
188 | </html> |
183 | </html> |
189 | EOF |
184 | EOF |