X-Git-Url: https://git.sesse.net/?p=pr0n;a=blobdiff_plain;f=perl%2FSesse%2Fpr0n%2FCommon.pm;h=76da6befeb3466f6620f354ad5a8ef251b7f99a6;hp=f91526001efcea11858a187b0db1bea2bcdf6922;hb=59921df12b46d8d77698a7a5fb268fc98c6c2c4c;hpb=2d6536cab108c937e2af49f7dcf15f2230f44d1a diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index f915260..76da6be 100644 --- a/perl/Sesse/pr0n/Common.pm +++ b/perl/Sesse/pr0n/Common.pm @@ -26,13 +26,19 @@ BEGIN { use Exporter (); our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - $VERSION = "v2.04"; + use Sesse::pr0n::Config; + eval { + require Sesse::pr0n::Config_local; + }; + + $VERSION = "v2.05"; @ISA = qw(Exporter); @EXPORT = qw(&error &dberror); %EXPORT_TAGS = qw(); @EXPORT_OK = qw(&error &dberror); - our $dbh = DBI->connect("dbi:Pg:dbname=pr0n;host=127.0.0.1", "pr0n", "EsVdwImY") + our $dbh = DBI->connect("dbi:Pg:dbname=pr0n;host=" . $Sesse::pr0n::Config::db_host, + $Sesse::pr0n::Config::db_username, $Sesse::pr0n::Config::db_password) or die "Couldn't connect to PostgreSQL database: " . DBI->errstr; our $mimetypes = new MIME::Types; @@ -134,7 +140,8 @@ sub get_dbh { if (!(defined($dbh) && $dbh->ping)) { # Try to reconnect Apache2::ServerUtil->server->log_error("Lost contact with PostgreSQL server, trying to reconnect..."); - unless ($dbh = DBI->connect("dbi:Pg:dbname=pr0n;host=127.0.0.1", "pr0n", "EsVdwImY")) { + unless ($dbh = DBI->connect("dbi:Pg:dbname=pr0n;host=" . $Sesse::pr0n::Config::db_host, + $Sesse::pr0n::Config::db_user, $Sesse::pr0n::Config::db_password)) { $dbh = undef; die "Couldn't connect to PostgreSQL database"; } @@ -262,7 +269,7 @@ sub ensure_cached { my ($r, $filename, $id, $dbwidth, $dbheight, $infobox, $xres, $yres, @otherres) = @_; my $fname = get_disk_location($r, $id); - unless (defined($xres) && ($xres < $dbheight || $yres < $dbwidth || $dbwidth == -1 || $dbheight == -1)) { + unless (defined($xres) && ($xres < $dbheight || $yres < $dbwidth || $dbwidth == -1 || $dbheight == -1 || $xres == -1)) { return ($fname, 0); } @@ -334,9 +341,11 @@ sub ensure_cached { $quality = 80; } - $cimg->Resize(width=>$nwidth, height=>$nheight, filter=>$filter); + if ($xres != -1) { + $cimg->Resize(width=>$nwidth, height=>$nheight, filter=>$filter); + } - if (($nwidth >= 800 || $nheight >= 600) && $infobox == 1) { + if (($nwidth >= 800 || $nheight >= 600 || $xres == -1) && $infobox == 1) { make_infobox($cimg, $info, $r); }