diff options
Diffstat (limited to 'lib/VNDB/Util')
-rw-r--r-- | lib/VNDB/Util/Auth.pm | 23 | ||||
-rw-r--r-- | lib/VNDB/Util/BrowseHTML.pm | 4 | ||||
-rw-r--r-- | lib/VNDB/Util/CommonHTML.pm | 30 | ||||
-rw-r--r-- | lib/VNDB/Util/FormHTML.pm | 4 | ||||
-rw-r--r-- | lib/VNDB/Util/LayoutHTML.pm | 13 |
5 files changed, 23 insertions, 51 deletions
diff --git a/lib/VNDB/Util/Auth.pm b/lib/VNDB/Util/Auth.pm index a1c6cf08..0c3b5b73 100644 --- a/lib/VNDB/Util/Auth.pm +++ b/lib/VNDB/Util/Auth.pm @@ -5,7 +5,7 @@ package VNDB::Util::Auth; use strict; use warnings; use Exporter 'import'; -use Digest::SHA qw|sha1 sha1_hex sha256|; +use Digest::SHA qw|sha1 sha1_hex|; use Crypt::URandom 'urandom'; use Crypt::ScryptKDF 'scrypt_raw'; use Encode 'encode_utf8'; @@ -112,16 +112,7 @@ sub _authCheck { my $d = $self->dbUserGet(username => $user, what => 'extended notifycount')->[0]; return 0 if !$d->{id}; - # Old-style hashes - if(length $d->{passwd} == 41) { - return 0 if _authPreparePassSha256($self, $pass, substr $d->{passwd}, 0, 9) ne $d->{passwd}; - $self->{_auth} = $d; - # Update database with new hash format, now that we have the plain text password - $self->dbUserEdit($d->{id}, passwd => $self->authPreparePass($pass)); - return 1; - } - - # New scrypt hashes + # scrypt format if(length $d->{passwd} == 46) { my($N, $r, $p, $salt) = unpack 'NCCa8', $d->{passwd}; return 0 if $self->authPreparePass($pass, $salt, $N, $r, $p) ne $d->{passwd}; @@ -144,16 +135,6 @@ sub authPreparePass { } -# Same as authPreparePass, but for the old sha256 hash. -# Arguments: pass, optionally salt -# Returns: encrypted password (as a binary string) -sub _authPreparePassSha256 { - my($self, $pass, $salt) = @_; - $salt ||= encode_utf8(randomascii(9)); - return $salt.sha256($self->{global_salt} . encode_utf8($pass) . $salt); -} - - # Generates a random token that can be used to reset the password. # Returns: token (hex string), token-encrypted (binary string) sub authPrepareReset { diff --git a/lib/VNDB/Util/BrowseHTML.pm b/lib/VNDB/Util/BrowseHTML.pm index b54ad5d9..d57c0546 100644 --- a/lib/VNDB/Util/BrowseHTML.pm +++ b/lib/VNDB/Util/BrowseHTML.pm @@ -137,11 +137,11 @@ sub htmlBrowseHist { ], row => sub { my($s, $n, $i) = @_; - my $revurl = "/$i->{type}$i->{iid}.$i->{rev}"; + my $revurl = "/$i->{type}$i->{itemid}.$i->{rev}"; Tr; td class => 'tc1_1'; - a href => $revurl, "$i->{type}$i->{iid}"; + a href => $revurl, "$i->{type}$i->{itemid}"; end; td class => 'tc1_2'; a href => $revurl, ".$i->{rev}"; diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm index 7b3fa673..b576e4ad 100644 --- a/lib/VNDB/Util/CommonHTML.pm +++ b/lib/VNDB/Util/CommonHTML.pm @@ -133,12 +133,12 @@ sub htmlHiddenMessage { my($self, $type, $obj) = @_; return 0 if !$obj->{hidden}; my $board = $type =~ /[cs]/ ? 'db' : $type eq 'r' ? 'v'.$obj->{vn}[0]{vid} : $type.$obj->{id}; - # fetch edit summary (not present in $obj because the changes aren't fetched) - my $editsum = $type eq 'v' ? $self->dbVNGet(id => $obj->{id}, what => 'changes')->[0]{comments} - : $type eq 'r' ? $self->dbReleaseGet(id => $obj->{id}, what => 'changes')->[0]{comments} - : $type eq 'c' ? $self->dbCharGet(id => $obj->{id}, what => 'changes')->[0]{comments} - : $type eq 's' ? $self->dbStaffGet(id => $obj->{id}, what => 'changes')->[0]{comments} - : $self->dbProducerGet(id => $obj->{id}, what => 'changes')->[0]{comments}; + # fetch edit summary (not present in $obj, requires the db*GetRev() methods) + my $editsum = $type eq 'v' ? $self->dbVNGetRev(id => $obj->{id})->[0]{comments} + : $type eq 'r' ? $self->dbReleaseGetRev(id => $obj->{id})->[0]{comments} + : $type eq 'c' ? $self->dbCharGetRev(id => $obj->{id})->[0]{comments} + : $type eq 's' ? $self->dbStaffGetRev(id => $obj->{id})->[0]{comments} + : $self->dbProducerGetRev(id => $obj->{id})->[0]{comments}; div class => 'mainbox'; h1 $obj->{title}||$obj->{name}; div class => 'warning'; @@ -183,7 +183,7 @@ sub htmlRevision { a class => 'prev', href => sprintf('/%s%d.%d', $type, $new->{id}, $new->{rev}-1), '<- '.mt '_revision_previous' if $new->{rev} > 1; a class => 'next', href => sprintf('/%s%d.%d', $type, $new->{id}, $new->{rev}+1), mt('_revision_next').' ->' - if $new->{cid} != $new->{latest}; + if !$new->{lastrev}; p class => 'center'; a href => "/$type$new->{id}", "$type$new->{id}"; end; @@ -204,12 +204,12 @@ sub htmlRevision { table class => 'stripe'; thead; Tr; - td; lit ' '; end; + td; lit ' '; end; td; revheader($self, $type, $old); end; td; revheader($self, $type, $new); end; end; Tr; - td; lit ' '; end; + td; lit ' '; end; td colspan => 2; b mt '_revision_edit_summary', $new->{rev}; br; br; @@ -310,7 +310,7 @@ sub htmlEditMessage { } end; end; - if($obj && $obj->{latest} != $obj->{cid}) { + if($obj && !$obj->{lastrev}) { div class => 'warning'; h2 mt '_editmsg_revert_title'; p mt '_editmsg_revert_msg', $num; @@ -329,11 +329,7 @@ sub htmlItemMessage { if($obj->{locked}) { p class => 'locked', mt '_itemmsg_locked'; - } elsif(!$self->authInfo->{id}) { - p class => 'locked'; - lit mt '_itemmsg_login', '/u/login'; - end; - } elsif(!$self->authCan('edit')) { + } elsif($self->authInfo->{id} && !$self->authCan('edit')) { p class => 'locked', mt '_itemmsg_denied'; } } @@ -439,6 +435,7 @@ sub htmlSearchBox { sub htmlRGHeader { my($self, $title, $type, $obj) = @_; + # This used to be a good test for inline SVG support, but I'm not sure it is nowadays. if(($self->reqHeader('Accept')||'') !~ /application\/xhtml\+xml/) { $self->htmlHeader(title => $title); $self->htmlMainTabs($type, $obj, 'rg'); @@ -452,8 +449,7 @@ sub htmlRGHeader { $self->htmlFooter; return 1; } - $self->resHeader('Content-Type' => 'application/xhtml+xml; charset=UTF-8'); - $self->htmlHeader(title => $title, svg => 1); + $self->htmlHeader(title => $title); $self->htmlMainTabs($type, $obj, 'rg'); return 0; } diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm index 22eeb4c5..e1f3bdfc 100644 --- a/lib/VNDB/Util/FormHTML.pm +++ b/lib/VNDB/Util/FormHTML.pm @@ -99,7 +99,7 @@ sub htmlFormPart { if(/check/) { Tr class => 'newfield'; td class => 'label'; - lit ' '; + lit ' '; end; td class => 'field'; input type => 'checkbox', name => $o{short}, id => $o{short}, tabindex => 10, @@ -122,7 +122,7 @@ sub htmlFormPart { } elsif($o{label}) { txt $o{label}; } else { - lit ' '; + lit ' '; } end; } diff --git a/lib/VNDB/Util/LayoutHTML.pm b/lib/VNDB/Util/LayoutHTML.pm index e041960a..f2344fc5 100644 --- a/lib/VNDB/Util/LayoutHTML.pm +++ b/lib/VNDB/Util/LayoutHTML.pm @@ -17,11 +17,8 @@ sub htmlHeader { # %options->{ title, noindex, search, feeds, svg } $skin = $self->{skin_default} if !$self->{skins}{$skin} || !-d "$VNDB::ROOT/static/s/$skin"; # heading - html lang => $self->{l10n}->language_tag(), $o{svg} ? ( - doctype => 'xhtml-math-svg', - 'xmlns:svg' => 'http://www.w3.org/2000/svg', - 'xmlns:xlink' => 'http://www.w3.org/1999/xlink' - ) : (); + lit '<!DOCTYPE HTML>'; + tag 'html', lang => $self->{l10n}->language_tag(); head; title $o{title}; Link rel => 'shortcut icon', href => '/favicon.ico', type => 'image/x-icon'; @@ -79,7 +76,7 @@ sub _menu { form action => '/v/all', method => 'get', id => 'search'; fieldset; legend 'Search'; - input type => 'text', class => 'text', id => 'sq', name => 'sq', value => $o{search}||mt('_menu_emptysearch'); + input type => 'text', class => 'text', id => 'sq', name => 'sq', value => $o{search}||'', placeholder => mt('_menu_emptysearch'); input type => 'submit', class => 'submit', value => 'Search'; end; end; @@ -104,9 +101,7 @@ sub _menu { if($self->authCan('edit')) { a href => '/v/add', mt '_menu_addvn'; br; a href => '/p/new', mt '_menu_addproducer'; br; - if($self->authCan('staffedit')) { - a href => '/s/new', mt '_menu_addstaff'; br; - } + a href => '/s/new', mt '_menu_addstaff'; br; a href => '/c/new', mt '_menu_addcharacter'; br; } br; |