#!/usr/bin/perl use CGI qw(:standard); my ($year) = param("yr"); my ($exclusive) = param("ex"); $temp = param("ppl"); $temp =~ s/\(/\\\(/gi; $temp =~ s/\)/\\\)/gi; my (@people) = split(/xyz/, $temp); #my (@people) = split(/xyz/, ""); print "Content-type: text/html\n\n"; $holdMe = searchPics($exclusive, $year, @people); if ($holdMe) { print($holdMe); } else { print "Search Error

There was an error processing your search

"; } # #foreach (@people) #{ # print "$_\n"; #} ############################################################ sub searchPics { my ($exclusive, $year, @people) = @_; if (@people < 1) { push (@people, "nobody"); } open (TEMP, "../album/picturelist.xml") || return (""); $onWeb = 0; $offWeb = 0; @results; while() { $line = $_; if ($year == "" || $year == getTag($line, year)) { $AOK = 1; foreach (@people) { if ($line =~ m/$_<\/person>/i) { # Do Nothing } else { $AOK = 0; } } if ($AOK) { if (getAtt($line, "picture", "web") =~ m/true/i) { $onWeb++; push(@results, getTag($line, "filename")); } else { $offWeb++; } } } } $stringOut = "YellowSlicker Picture Search Results"; $stringOut .= "

YellowSlicker Picture Search Results

"; if ($onWeb && $offWeb) { $stringOut .= "

Your search turned up $onWeb pictures. Also, there are another $offWeb pictures matching your criteria that are currently offline.

"; } elsif ($onWeb && !$offWeb) { $stringOut .= "

Your search turned up $onWeb pictures.

"; } elsif (!$onWeb && $offWeb) { $stringOut .= "

Your search returned no pictures, but there are $offWeb pictures matching your search that are currently offline.

"; } elsif (!$onWeb && !$offWeb) { $stringOut .= "

There were no pictures found matching your search criteria.

"; } if ($offWeb) { $stringOut .= "

If you are interested in viewing pictures that are currently offline, please contact Nathan via e-mail.

"; } foreach (@results) { $stringOut .= ""; } $stringOut .= ""; return ($stringOut); } ############################################################ sub getTag { my ($string, $element) = @_; my ($start, $end); if ($string =~ /<$element>/) { $start = index($string, "<$element>"); if ($start >= 0) { $start = (index($string, ">", $start) + 1); $end = index($string, "<", $start); if ($start >= 0) { return (substr($string, $start, $end-$start)) } } } return (""); } ############################################################ sub getAtt { my ($string, $element, $attribute) = @_; if ($string =~ /<$element.*$attribute\s*=".*"/) { $string = substr($string, index($string, "<$element")); $string = substr($string, index($string, $attribute)); $string = substr($string, index($string, "\"")+1); $string = substr($string, 0, index($string, "\"")); return ($string) } return (""); }