diff --git a/.gitignore b/.gitignore

new file mode 100644

index 0000000000000000000000000000000000000000..b6afdb2a2eda3babe930cf5b4a66a982d2a8c335

--- /dev/null

+++ b/.gitignore

@@ -0,0 +1 @@

+photo_stats.db

diff --git a/phosta.pl b/phosta.pl

index 44e38b8be3445d88c2b5b4974c6f62185ae8fb59..2aa70317e9cb9c7f56b4a355790057bddd11e6ed 100755

--- a/phosta.pl

+++ b/phosta.pl

@@ -21,18 +21,18 @@ my $VERSION = '0.5';

my $PROGRAM = 'Photo Stats';

# read commandline switches

-our $opt_d=getcwd . "/photo_stats.db";

+our $opt_D=getcwd . "/photo_stats.db";

our $opt_p='';

our $opt_c=0;

-our $opt_q=0;

our $opt_s='';

our $opt_g='';

-getopts('cqp:g:s:d:') or die "Invalid parameters provided! See 'phosta.pl --help' for more details.";

-my $dsn = "DBI:SQLite:dbname=$opt_d";

+getopts('cp:g:s:d:') or die "Invalid parameters provided! See 'phosta --help' for more details.";

+validate() or die "Invalid parameters provided! See 'phosta --help' for more details.";

+my $dsn = "DBI:SQLite:dbname=$opt_D";

-if ($opt_c) { unlink $opt_d; }

-if ( !-e $opt_d ) { create_db($opt_d) or die 'database could not be created'; }

+if ($opt_c) { unlink $opt_D; }

+if ( !-e $opt_D ) { create_db($opt_D) or die 'database could not be created'; }

if ( $opt_p ne '' ) {

populate_db($opt_p);

@@ -42,6 +42,20 @@

query_db($opt_s, $opt_g);

exit 0;

+

+sub validate

+{

+ my @group_params = ('year', 'month', 'week', '');

+ if ( ! ($opt_g ~~ @group_params) ) { return 0; }

+

+ my @select_params = ('maker', 'model', 'lens', 'aperture', 'exposuretime', 'iso', 'focallength', 'focallength35mm', '');

+ foreach (split (/,/, $opt_s))

+ {

+ if ( ! ($_ ~~ @select_params) ) { return 0; }

+ }

+

+ return 1;

+}

sub create_db

{

@@ -82,6 +96,7 @@ }

$dbh->disconnect();

say sprintf('%5d', $emptycount). ' image files skipped due to missing EXIF data';

say sprintf('%5d', $errorcount). ' image files skipped due to errors';

+ say "Updated local database $opt_D.";

}

sub get_sql

@@ -180,7 +195,7 @@ say '';

say 'usage: phosta(.pl) [options]';

say '';

say 'options:';

- say ' -d <file> : path and name of the db file to use';

+ say ' -D <file> : path and name of the db file to use';

say ' -p <folder> : populate database from the files in the specified folder';

say ' -c : clear the database before populating with data from the folder';

say ' -g : (query mode) group by time range, defaults to total (which means no grouping by time range)';