X-Git-Url: https://git.sesse.net/?p=pr0n;a=blobdiff_plain;f=perl%2FSesse%2Fpr0n%2FCommon.pm;h=c34aa65f1df96e3a01eaeeb6c837f686792d93b9;hp=a43c50af72c2b0b8974521765c171ba3c32e3487;hb=c418c8bb8654b7aa1ea16357fe259ef65022cab8;hpb=0790a2542347fea51482ae2c4aa3d128a8c87721 diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index a43c50a..c34aa65 100644 --- a/perl/Sesse/pr0n/Common.pm +++ b/perl/Sesse/pr0n/Common.pm @@ -34,7 +34,7 @@ BEGIN { require Sesse::pr0n::Config_local; }; - $VERSION = "v2.21"; + $VERSION = "v2.30"; @ISA = qw(Exporter); @EXPORT = qw(&error &dberror); %EXPORT_TAGS = qw(); @@ -91,7 +91,7 @@ sub header { $quote = LWP::Simple::get("http://itk.samfundet.no/include/quotes.cli.php"); $quote = "Error: Could not fetch quotes." if (!defined($quote)); } - Sesse::pr0n::Templates::print_template($r, "header", { title => $title, quotes => $quote }); + Sesse::pr0n::Templates::print_template($r, "header", { title => $title, quotes => Encode::decode_utf8($quote) }); } sub footer { @@ -198,28 +198,32 @@ sub update_image_info { } } - $dbh->do('UPDATE images SET width=?, height=?, date=? WHERE id=?', - undef, $width, $height, $datetime, $id) - or die "Couldn't update width/height in SQL: $!"; + { + local $dbh->{AutoCommit} = 0; - $dbh->do('DELETE FROM exif_info WHERE image=?', - undef, $id) - or die "Couldn't delete old EXIF information in SQL: $!"; + $dbh->do('UPDATE images SET width=?, height=?, date=? WHERE id=?', + undef, $width, $height, $datetime, $id) + or die "Couldn't update width/height in SQL: $!"; - my $q = $dbh->prepare('INSERT INTO exif_info (image,tag,value) VALUES (?,?,?)') - or die "Couldn't prepare inserting EXIF information: $!"; + $dbh->do('DELETE FROM exif_info WHERE image=?', + undef, $id) + or die "Couldn't delete old EXIF information in SQL: $!"; - for my $key (keys %$info) { - next if ref $info->{$key}; - $q->execute($id, $key, $info->{$key}) - or die "Couldn't insert EXIF information in database: $!"; - } + my $q = $dbh->prepare('INSERT INTO exif_info (image,tag,value) VALUES (?,?,?)') + or die "Couldn't prepare inserting EXIF information: $!"; + + for my $key (keys %$info) { + next if ref $info->{$key}; + $q->execute($id, $key, guess_charset($info->{$key})) + or die "Couldn't insert EXIF information in database: $!"; + } - # update the last_picture cache as well (this should of course be done - # via a trigger, but this is less complicated :-) ) - $dbh->do('UPDATE last_picture_cache SET last_picture=GREATEST(last_picture, ?) WHERE event=(SELECT event FROM images WHERE id=?)', - undef, $datetime, $id) - or die "Couldn't update last_picture in SQL: $!"; + # update the last_picture cache as well (this should of course be done + # via a trigger, but this is less complicated :-) ) + $dbh->do('UPDATE last_picture_cache SET last_picture=GREATEST(last_picture, ?) WHERE event=(SELECT event FROM images WHERE id=?)', + undef, $datetime, $id) + or die "Couldn't update last_picture in SQL: $!"; + } } sub check_access { @@ -440,6 +444,8 @@ sub make_infobox { my ($a, $b) = ($1, $2); my $gcd = gcd($a, $b); push @classic_fields, ($a/$gcd . "/" . $b/$gcd . "s"); + } elsif (defined($info->{'ExposureTime'}) && $info->{'ExposureTime'} =~ /^(\d+)$/) { + push @classic_fields, ($1 . "s"); } if (defined($info->{'FNumber'}) && $info->{'FNumber'} =~ /^(\d+)\/(\d+)$/) { my $f = $1/$2; @@ -465,7 +471,11 @@ sub make_infobox { push @classic_fields, $info->{'ISOSetting'} . " ISO"; } - push @classic_fields, $info->{'ExposureBiasValue'} . " EV" if (defined($info->{'ExposureBiasValue'}) && $info->{'ExposureBiasValue'} != 0); + if (defined($info->{'ExposureBiasValue'}) && $info->{'ExposureBiasValue'} != 0) { + push @classic_fields, $info->{'ExposureBiasValue'} . " EV"; + } elsif (defined($info->{'ExposureCompensation'}) && $info->{'ExposureCompensation'} != 0) { + push @classic_fields, $info->{'ExposureCompensation'} . " EV"; + } if (scalar @classic_fields > 0) { push @lines, join(', ', @classic_fields);