]> git.sesse.net Git - pr0n/blobdiff - perl/Sesse/pr0n/Common.pm
Invalidate the cache on adding and deleting images.
[pr0n] / perl / Sesse / pr0n / Common.pm
index be4385ae712ec60de351bbccb68976d35601ec8c..e3b33324bcb8de120b80187cc777360d6deb63c5 100644 (file)
@@ -31,7 +31,7 @@ BEGIN {
                require Sesse::pr0n::Config_local;
        };
 
-       $VERSION     = "v2.05";
+       $VERSION     = "v2.10";
        @ISA         = qw(Exporter);
        @EXPORT      = qw(&error &dberror);
        %EXPORT_TAGS = qw();
@@ -134,8 +134,12 @@ sub get_query_string {
 }
 
 sub print_link {
-       my ($r, $title, $baseurl, $param, $defparam) = @_;
-       my $str = "<a href=\"$baseurl" . get_query_string($param, $defparam) . "\">$title</a>";
+       my ($r, $title, $baseurl, $param, $defparam, $accesskey) = @_;
+       my $str = "<a href=\"$baseurl" . get_query_string($param, $defparam) . "\"";
+       if (defined($accesskey) && length($accesskey) == 1) {
+               $str .= " accesskey=\"$accesskey\"";
+       }
+       $str .= ">$title</a>";
        $r->print($str);
 }
 
@@ -145,7 +149,7 @@ sub get_dbh {
                # 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=" . $Sesse::pr0n::Config::db_host,
-                       $Sesse::pr0n::Config::db_user, $Sesse::pr0n::Config::db_password)) {
+                       $Sesse::pr0n::Config::db_username, $Sesse::pr0n::Config::db_password)) {
                        $dbh = undef;
                        die "Couldn't connect to PostgreSQL database";
                }
@@ -182,10 +186,10 @@ sub update_width_height {
        # Also find the date taken if appropriate (from the EXIF tag etc.)
        my $info = Image::ExifTool::ImageInfo(get_disk_location($r, $id));
        my $datetime = undef;
-
+                       
        if (defined($info->{'DateTimeOriginal'})) {
                # Parse the date and time over to ISO format
-               if ($info->{'DateTimeOriginal'} =~ /^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)$/ && $1 > 1990) {
+               if ($info->{'DateTimeOriginal'} =~ /^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)(?:\+\d\d:\d\d)?$/ && $1 > 1990) {
                        $datetime = "$1-$2-$3 $4:$5:$6";
                }
        }