|;
}
my %pagetitles = (
faq => 'Frequently Asked Questions',
userlogin => 'Login',
userreg => 'Register a new account',
userpass => 'Forgot your password?',
home => 'Visual Novel Database',
pbrowse => 'Browse producers',
userlist => 'Browse users',
tindex => 'Discussion board index',
ttag => sub {
return ($p{ttag}{obj} ? 'Related discussions for ' : '').$p{ttag}{title} },
tthread => sub {
return $p{tthread}{t}{title} },
tedit => sub {
return $p{tedit}{p} ? 'Edit post' :
$p{tedit}{t} ? 'Reply to thread' : 'Start a new thread' },
userpage => sub {
return 'User: '.$p{userpage}{user}{username} },
vnlist => 'My visual novel list (old)',
wlist => sub {
return $p{wlist}{user}{username} eq $p{AuthUsername} ? 'My wishlist' : ($p{wlist}{user}{username}.'\'s wishlist'); },
rlist => sub {
return $p{rlist}{user}{username} eq $p{AuthUsername} ? 'My visual novel list' : ($p{rlist}{user}{username}.'\'s visual novel list'); },
useredit => sub {
return !$p{useredit}{adm} ? 'My account' : 'Edit '.$p{useredit}{form}{username}.'\'s account'; },
ppage => sub {
return $p{ppage}{prod}{name} },
pedit => sub {
return $p{pedit}{id} ? sprintf('Edit %s', $p{pedit}{form}{name}) : 'Add a new producer'; },
vnedit => sub {
return $p{vnedit}{id} ? sprintf('Edit %s', $p{vnedit}{form}{title}) : 'Add a new visual novel'; },
redit => sub {
return $p{redit}{id} ? sprintf('Edit %s', $p{redit}{rel}{title}) : sprintf('Add release to %s', $p{redit}{vn}{title}); },
vnpage => sub { return $p{vnpage}{vn}{title}; },
vnrg => sub { return 'Relations for '.$p{vnrg}{vn}{title} },
vnstats => sub { return 'User statistics for '.$p{vnstats}{vn}{title} },
vnbrowse => sub {
return $p{vnbrowse}{chr} eq 'search' ? 'Visual novel search' :
$p{vnbrowse}{chr} eq 'mod' ? 'Visual Novels awaiting moderation' :
$p{vnbrowse}{chr} eq 'all' ? 'Browse all visual novels' :
$p{vnbrowse}{chr} eq '0' ? 'Browse by char: Other' :
sprintf 'Browse by char: %s', uc $p{vnbrowse}{chr}; },
rpage => sub {
return $p{rpage}{rel}{romaji} || $p{rpage}{rel}{title} },
hist => sub {
return !$p{hist}{id} || !$p{hist}{type} ? 'Recent changes' :
$p{hist}{type} eq 'u' ? 'Recent changes by '.$p{hist}{title} : 'Edit history of '.$p{hist}{title}; },
docs => sub { $p{docs}{title} },
error => sub {
$p{error}{err} eq 'notfound' ? '404 Page Not Found' : 'Error Parsing Form' },
);
sub gettitle{$p{$_}&&($p{PageTitle}=ref($pagetitles{$_}) eq 'CODE' ? &{$pagetitles{$_}} : $pagetitles{$_}) for (keys%pagetitles);}
#
# F O R M E R R O R H A N D L I N G
#
my %formerr_names = (
# this list is rather incomplete...
mail => 'Email',
username => 'Username',
userpass => 'Password',
pass1 => 'Password',
pass2 => 'Password (second)',
title => 'Title',
desc => 'Description',
rel => 'Relation',
romaji => 'Romanized title',
lang => 'Language',
web => 'Website',
released => 'Release date',
platforms => 'Platforms',
media => 'Media',
name => 'Name',
vn => 'Visual novel relations',
l_vnn => 'Visual-novels.net link',
comm => 'Edit summary',
msg => 'Message',
);
my @formerr_msgs = (
sub { return sprintf 'Field "%s" is required.', @_ },
sub { return sprintf '%s should have at least %d characters.', @_ },
sub { return sprintf '%s is too large! Only %d characters allowed.', @_ },
sub { return
$_[1] eq 'mail' ? 'Invalid email address' :
$_[1] eq 'url' ? 'Invalid URL' :
$_[1] eq 'pname' ? sprintf('%s can only contain alfanumeric characters!', $_[0]) :
$_[1] eq 'asciiprint' ? sprintf('Only ASCII characters are allowed at %s', $_[0]) :
$_[1] eq 'int' ? sprintf('%s should be a number!', $_[0]) :
$_[1] eq 'gtin' ? 'Not a valid JAN, UPC or EAN code!' : '';
},
sub { return sprintf '%s: invalid item selected', @_ },
sub { return 'Invalid unicode, are you sure your browser works fine?' },
);
my %formerr_exeptions = (
loginerr => 'Invalid username or password',
badpass => 'Passwords do not match',
usrexists => 'Username already exists, please choose an other one',
mailexists => 'There already is a user with that email address, please request a new password if you forgot it',
nomail => 'No user found with that email address',
nojpeg => 'Image is not in JPEG or PNG format!',
toolarge => 'Image is too large (in filesize), try to compress it a little',
wrongtag => 'Wrong tag selected!',
);
sub formerr {
my @err = ref $_[0] eq 'ARRAY' ? @{$_[0]} : ();
return '' if $#err < 0;
my @msgs;
my $ret = '
Error: