#!/usr/bin/perl #------------------------------------------------------------------- # events.cgi v1.0 1999 05 10 ekb@ivm.net # # Events database - central browsing cgi # # [1999 05 10] v1.0 Initial version # (stolen from the V-Project) #------------------------------------------------------------------- require "cgi-lib.pl"; &ReadParse(); require "v-config"; require "v-db"; require "v-misc"; require "v-tmpl"; #----------------------------- # Gueltige Aktionen: 0-1 # Default-Aktion: 0 # # Nr Aktion Was anzeigen? # # 0 show searchmask find.tmpl # 1 search by mask overview.tmpl (filled) # 2 open edit mask edit.tmpl (filled) # 3 commit changes edit.tmpl (filled) # 99 Gewuenschtes Template ausgeben #----------------------------- #--- Pre-Work --------------------------------------------------- #-- Determine action $action = $in{act} || 0; $action=0 if ((($action<0) || ($action>3)) && ($action != 99)); print STDERR "ACTION: $action ($in{act})\n"; #-- Set available globals $theimage = $in{image} if ($in{image}); $thestart = $in{start} || 0; #--- Dispatch --------------------------------------------------- if ($action == 0) { &showsearchmask(); } elsif ($action == 1) { &search(); } elsif ($action == 2) { &showeditmask(); } elsif ($action == 3) { &savechanges(); } elsif ($action == 99) { &showtemplate(); } exit 0; #--- Action functions ------------------------------------------- #--------------------------------- # showsearchmask # #--------------------------------- sub showsearchmask { #-- fill $thedata{select-Events} with id:Event pairs my @list = &GenericSelectMultiple("events","","AND","*"); my $list = ""; my $id; foreach $id (@list) { my %event = &GenericReadByID("events",$id); if ($event{ID}) { $list .= ",".join(":",$event{ID},$event{Event}); } } $list =~ s/^,//; $thedata{'select--Events'} = $list; #-- fill $thedata{select-Photographers} with id:Photographer pairs my @list = &GenericSelectMultiple("photographers","","AND","*"); my $list = ""; foreach $id (@list) { my %photographer = &GenericReadByID("photographers",$id); if ($photographer{ID}) { $list .= ",".join(":",$photographer{ID},$photographer{Name}." (".$photographer{EMail}.")"); } } $list =~ s/^,//; $thedata{'select--Photographers'} = $list; Goto(0); } #--------------------------------- # search # #--------------------------------- sub search { # 1. evaluate fields # $in{Event} # $in{Photographer} # $in{Keywords} # $in{Persons} # $in{Description} # $in{ANDOR} $Event = $in{Event} || ""; $Photographer = $in{Photographer} || ""; $Keywords = $in{Keywords} || ""; $Persons = $in{Persons} || ""; $Description = $in{Description} || ""; $ANDOR = $in{ANDOR} || "AND"; # 2. build queries $query = ""; $query .= "(Event LIKE \"%$Event%\") $ANDOR " if ($Event ne ""); $query .= "(Photographer LIKE \"%$Photographer%\") $ANDOR " if ($Photographer ne ""); $query .= "(Keywords LIKE \"%$Keywords%\") $ANDOR " if ($Keywords ne ""); $query .= "(Persons LIKE \"%$Persons%\") $ANDOR " if ($Persons ne ""); $query .= "(Description LIKE \"%$Description%\") $ANDOR " if ($Description ne ""); $query =~ s/ $ANDOR $//; $query = "WHERE $query" if ($query ne ""); # 3. obtain image list @theidlist = &GenericSelectMultiple("images",$query,"ASIS","*"); print STDERR "Going towards (1)\n"; Goto(1); } #--------------------------------- # showeditmask # #--------------------------------- sub showeditmask { $theobject=$in{image}; print STDERR "Got Image ID $theobject\n"; %theobject = &GenericReadByID("images",$theobject); Goto(2); } #--------------------------------- # savechanges # #--------------------------------- sub savechanges { $ok=0; $ok=1 if (($in{login} eq "elmi") && ($in{pass} eq "chambourcy")); $ok=1 if (($in{login} eq "martin") && ($in{pass} eq "bengi")); $ok=1 if (($in{login} eq "jonas") && ($in{pass} eq "NetHammer")); $ok=1 if (($in{login} eq "jewa") && ($in{pass} eq "wahnesworld")); $ok=1 if (($in{login} eq "holger") && ($in{pass} eq "humbug")); $ok=1 if (($in{login} eq "ingo") && ($in{pass} eq "golliVibes")); $ok=1 if (($in{login} eq "christian") && ($in{pass} eq "detebe")); $ok=1 if (($in{login} eq "petra") && ($in{pass} eq "zucker")); $ok=1 if (($in{login} eq "hermann") && ($in{pass} eq "h-man")); &Goto(0) if (!$ok); $theobject=$in{image}; print STDERR "Got Image ID $theobject\n"; %theobject = &GenericReadByID("images",$theobject); $Persons = $in{Persons} || ""; $Keywords = $in{Keywords} || ""; $Description = $in{Description} || ""; $ThumbURL = $in{ThumbURL} || ""; $ImgURL = $in{ImgURL} || ""; $theobject{Persons} = $Persons if ($Persons ne ""); $theobject{Keywords} = $Keywords if ($Keywords ne ""); $theobject{Description} = $Description if ($Description ne ""); $theobject{ThumbURL} = $ThumbURL if ($ThumbURL ne ""); $theobject{ImgURL} = $ImgURL if ($ImgURL ne ""); $theobject{LastChange} = $in{login}; &GenericUpdate("images",%theobject); &showeditmask(); } sub showtemplate { }