27 |
} |
} |
28 |
use Message::Util::Error; |
use Message::Util::Error; |
29 |
|
|
30 |
|
BEGIN { |
31 |
|
if ($main::ENV{REQUEST_URI} =~ /\#/) { |
32 |
|
require SuikaWiki::Output::HTTP; |
33 |
|
my $out = SuikaWiki::Output::HTTP->new; |
34 |
|
$out->{status_code} = 401; |
35 |
|
$out->{status_phrase} = q<Request-URI MUST NOT have Fragment Identifier>; |
36 |
|
$out->{entity}->{media_type} = q<text/html>; |
37 |
|
$out->{entity}->{charset} = q<iso-8859-1>; |
38 |
|
$out->{entity}->{language} = [q<en>]; |
39 |
|
$out->{entity}->{body_is_octet_stream} = 1; |
40 |
|
my $ua = $main::ENV{HTTP_USER_AGENT}; |
41 |
|
for ($ua) { |
42 |
|
s/&/&/g; s/</</g; s/([^\x20-\x7E])/sprintf '&#x%02X;', ord $1/ge; |
43 |
|
}; |
44 |
|
$out->{entity}->{body} = qq< |
45 |
|
<!DOCTYPE html SYSTEM> |
46 |
|
<title>401 Bad Request-URI</title> |
47 |
|
<h1>Bad Request-URI</h1> |
48 |
|
<p>Your Request-URI has fragment identifier but it is not allowed here. |
49 |
|
It might be a bug of your user agent ($ua). Please contact to the UA |
50 |
|
vendor.</p> |
51 |
|
>; |
52 |
|
$out->output (output => 'http-cgi'); |
53 |
|
exit; |
54 |
|
} |
55 |
|
} |
56 |
|
|
57 |
push our @Config, sub ($) { |
push our @Config, sub ($) { |
58 |
my $WIKI = shift; |
my $WIKI = shift; |
59 |
use Cwd qw(abs_path); |
use Cwd qw(abs_path); |
60 |
|
|
61 |
## -- Filesystem path mapping |
## -- Filesystem path mapping |
62 |
for ( |
for ( |
63 |
[db__cache__dir => q"./wikidata/lock/"], |
[db__cache__dir => q"./wikidata/cache/"], |
64 |
[db__cache_struct__file => q"./wikidata/lock/struct.db"], |
[db__cache_struct__file => q"./wikidata/cache/struct.db"], |
65 |
[db__content__dir => q"./wikidata/page/"], |
[db__content__dir => q"./wikidata/page/"], |
66 |
[db__content__error_log => q"./wikidata/log/db-content.log"], |
[db__content__error_log => q"./wikidata/log/db-content.log"], |
67 |
[db__bdb__home_dir => q"./wikidata/lock/"], |
[db__bdb__home_dir => q"./wikidata/lock/"], |
119 |
|
|
120 |
## Main content |
## Main content |
121 |
$wiki->{db}->_set_prop_db (content => {-db_open => sub { |
$wiki->{db}->_set_prop_db (content => {-db_open => sub { |
122 |
require SuikaWiki::DB::FileSystem::YukiWikiDBNS; |
require SuikaWiki::DB::FileSystem::LeafFile; |
123 |
SuikaWiki::DB::FileSystem::YukiWikiDBNS->new |
SuikaWiki::DB::FileSystem::LeafFile->new |
124 |
(directory => $wiki->{config}->{path_to}->{db__content__dir}, |
(base_directory => $wiki->{config}->{path_to}->{db__content__dir}, |
125 |
logfile => $wiki->{config}->{path_to}->{db__content__error_log}, |
directory_suffix => '.ns', |
126 |
suffix => '.txt', |
file_suffix => '.txt', |
127 |
root_key => $wiki->{config}->{page}->{Default}, |
root_key => $wiki->{config}->{page}->{Default}, |
128 |
-lock => $wiki->{var}->{db}->{lock_prop}->('content')); |
-lock => $wiki->{var}->{db}->{lock_prop}->('content')); |
129 |
}, -db_close => sub { |
}, -db_close => sub { |
130 |
my %opt = @_; |
my %opt = @_; |
197 |
|
|
198 |
## Referer Database (See Referer plugin module) |
## Referer Database (See Referer plugin module) |
199 |
$wiki->{db}->_set_prop_db (referer => {-db_open => sub { |
$wiki->{db}->_set_prop_db (referer => {-db_open => sub { |
200 |
require SuikaWiki::DB::Hash; |
require SuikaWiki::DB::FileSystem::Count; |
201 |
new SuikaWiki::DB::Hash constructor => sub { |
SuikaWiki::DB::FileSystem::Count->new |
202 |
tie my %db, 'BerkeleyDB::Hash', |
(base_directory => $wiki->{config}->{path_to}->{db__content__dir}, |
203 |
-Filename => 'referer.db', |
directory_suffix => '.ns', |
204 |
-Env => $bdbenv, |
file_suffix => '.ref', |
205 |
-Flags => DB_CREATE, |
root_key => $wiki->{config}->{page}->{Default}, |
206 |
-Mode => 0644; |
auto_mkdir => 0, |
207 |
\%db; |
-lock => $wiki->{var}->{db}->{lock_prop}->('referer')); |
208 |
}; |
}, -db_close => sub { |
209 |
|
my %opt = @_; |
210 |
|
$opt{prop_info}->{-db}->close; |
211 |
|
delete $opt{prop_info}->{-db}; |
212 |
}}); |
}}); |
213 |
|
|
214 |
## HTTP Request Logging Database (See RequestLog plugin module) |
## HTTP Request Logging Database (See RequestLog plugin module) |