[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS Update: gleipnir



Log Message:
-----------
Can display the images now.  No need for image path to be handled by the webserver.
Add my copyright.

Modified Files:
--------------
    gleipnir/public_html/gallery:
        picture.pl

Revision Data
-------------
Index: picture.pl
===================================================================
RCS file: /cvs/gleipnir/public_html/gallery/picture.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lpublic_html/gallery/picture.pl -Lpublic_html/gallery/picture.pl -u -r1.1 -r1.2
--- public_html/gallery/picture.pl
+++ public_html/gallery/picture.pl
@@ -3,7 +3,7 @@
 # $Id$
 # gallery_picture.pl - view large sized pictures with comment threads and tags
 #
-# Copyright (C) 2000-2003 Dan Brosemer <odin@cleannorth.org>
+# Copyright (C) 2000-2008 Dan Brosemer <odin@cleannorth.org>
 # Copyright (C) 2006 Jim Dew <jdew@yggdrasil.ca>
 # Copyright (C) 2006-2007 Josh Hayes-Sheen <grevian@gmail.com>
 #
@@ -31,6 +31,7 @@
 
 use strict;
 use Gleipnir;
+use MIME::Types;
 
 my $gleipnir = new Gleipnir;
 my $cgi      = $gleipnir->cgi;
@@ -51,15 +52,15 @@
 	my $cgi      = $gleipnir->cgi;
 	my $dbh      = $gleipnir->dbh;
 
-	my $pictureid = $cgi->param('id');
+	my $pictureid = $cgi->param('id')||($ENV{PATH_INFO} =~ m%/(\d+)\.(jpg|png|jpeg)$%i)[0];
 
   # build a where clause that will filter out pictures this user does not have access to
   my $ingroups = ();
   if ( defined( $gleipnir->groups ) )
-    {
-    $ingroups = join( ",", ( $gleipnir->groups ) );
-    $ingroups = "or g.gid in ($ingroups)" if ($ingroups);
-    }
+		{
+			$ingroups = join( ",", ( $gleipnir->groups ) );
+			$ingroups = "or g.gid in ($ingroups)" if ($ingroups);
+		}
 
   $ingroups = " gid is null " . $ingroups;
 
@@ -70,12 +71,24 @@
 	
 	my $cursor = $dbh->prepare($SQL);
 	$cursor->execute( $pictureid );
-
-	my $template = $gleipnir->template('gallery/picture');
-
 	my $ref = $cursor->fetchrow_hashref;
 
-	$template->param( 
+	if ($ENV{PATH_INFO} =~ m/(full|thumb)\/(\d+)\.(jpg|png|jpeg)$/i)
+		{
+			my $sel = ($1 eq 'full')?'imagedir':'thumbdir';
+			open IMG, $gleipnir->cfetch(dirs => $sel).'/'.$ref->{image_path};
+			binmode IMG;
+			my $img = join('', <DEFANGED_IMG>);
+			close IMG;
+			#return $gleipnir->body($gleipnir->cfetch(dirs => 'imagedir').'/'.$ref->{image_path});
+			$gleipnir->mimetype( ( MIME::Types::by_suffix($ref->{image_path}) )[0] );
+			return $gleipnir->body($img);
+		}
+	else
+		{
+			my $template = $gleipnir->template('gallery/picture');
+
+			$template->param( 
 											title => $ref->{title},
 											pictureid => $ref->{pictureid},
 											galleryid => $ref->{gallery},
@@ -87,6 +100,6 @@
 											gallery_desc => $ref->{description}
 									);
 
-	return $gleipnir->body( $template->output );
-	}
-
+			return $gleipnir->body( $template->output );
+		};
+	};


Main Menu:

Site Tools:


Here, spammer, have some addresses.