#!/usr/bin/perl ############################################################## # # This code is copyright iKing Networks 2000, 2001. # # iKing Networks offers no warranties on this script. # The user of the script is solely responsible for # any problems caused by installation of the script or use # of the script. # # All copyright notices regarding Arcadia scripts and iKing # Networks must remain intact on the scripts and in the HTML # for the scripts. # # http://www.ikingnet.com # ############################################################### # gallery.cgi #If you are on a Windows or other such server that runs scripts #in a directory other than the one they reside in, modify this #variable to the full path to uig.cfg. (Do not include a trailing #slash, / or \\) $UigPath = ""; #Modify this if you are on an old version of windows $slash = "/"; # flush the buffers $|=1; # find if it is a windows operating system my($dpath); my($windows); if ( ($^O eq 'MSWin32') || defined($ENV{'OS'}) ) { # this one for windows $windows = "true"; $dpath = "$ENV{'PATH_TRANSLATED'}"; }else{ # this one for unix type $windows = "false"; $dpath = "$ENV{'SCRIPT_FILENAME'}"; } push (@INC, "$dpath"); eval { # load required files if($UigPath eq "") { require 'uig.cfg'; } else { require $UigPath.$slash."uig.cfg"; } push(@INC, "$ScriptPath"); require $ScriptPath.$slash."display.cgi"; require $ScriptPath.$slash."uiglib.cgi"; require $ScriptPath.$slash."memory.cgi"; }; if ($@) { print "Content-type: text/html\n\n"; print qq~
Error including the required files:
~;
print qq~$@~;
print qq~~;
exit;
}
use CGI;
use CGI::Carp qw(fatalsToBrowser);
$cgi = new CGI;
#eval use_named_parameters to work with both old and new versions of CGI.pm
eval '$cgi->use_named_parameters';
#read cookie
$CookieData = $cgi->cookie("$CookieName");
if ($CookieData){
CrumbleCookie();
}
InitFromParameters();
LoadProfile();
#PrintHeader();
#print $cgi->dump();
if($cgi->param("func") eq "show") {
require $ScriptPath.$slash."categories.cgi";
require $ScriptPath.$slash."media.cgi";
ReadCategories();
$Category = $CategoryList[$CategoryIndex]->{NAME};
ShowMedia();
} elsif($CategoryIndex < 0) {
require $ScriptPath.$slash."categories.cgi";
ReadCategories();
ShowCategoryListing();
} else {
#Category is set and nothing else needs to be done so show gallery
require $ScriptPath.$slash."categories.cgi";
require $ScriptPath.$slash."media.cgi";
#initialize media
ReadCategories();
$Category = $CategoryList[$CategoryIndex]->{NAME};
ReadMedia($CategoryIndex);
$CategoryPath = $MediaPath.$CategoryPath;
ShowGallery();
}
########################################################################################
sub InitFromParameters
{
if($SortBy ne "") {
} elsif($cgi->param("selectedsort") ne "") {
$SortBy = $cgi->param("selectedsort");
} elsif($cgi->param("sort") ne "") {
$SortBy = $cgi->param("sort");
} else {
$SortBy = $DefaultSort;
}
if($cgi->param("Page") ne "") {
$Page = $cgi->param("Page");
} else {
$Page = 1;
}
if($cgi->param("Category") ne "") {
$CategoryID = int($cgi->param("Category"));
if(!@CategoryList) {
require $ScriptPath.$slash."categories.cgi";
ReadCategories();
}
$CategoryIndex = GetCategoryIndex($CategoryID);
if($CategoryIndex < 0) {
$Category = "NONE";
}
} else {
$CategoryIndex = -1;
}
}
########################################################################################
sub CategoryTree {
if($cgi->param("searchterm")) { return; }
if(!@CatTree) { BuildCatTree($CategoryIndex); }
my($html) = qq~
|
~; for(my($counter) = 0; $counter < @CatTree; $counter++) { for(my($index) = 0; $index < $CatTree[$counter]->{DEPTH}; $index++) { $html = $html." "; } if($CatTree[$counter]->{INDEX} == $cgi->param("Category")) { $html = $html.qq~ ~; } else { $html = $html.qq~ ~; } } $html = $html.qq~ |
| Sub Categories: | |||
|
~;
if($counter == @SubCats - 1 && @SubCats % 2 == 1) {
$html = $html.qq~~; } if($counter % 2 == 1) { $html = $html.qq~ | ||
|
Top ~; for(my($counter) = 0; $counter < @CatInline; $counter++) { if($filename eq "" && $CatInline[$counter]->{CATID} == $cgi->param("Category")) { $html = $html."> $CatInline[$counter]->{NAME} "; } else { $html = $html.qq~> $CatInline[$counter]->{NAME} ~; } } if($filename) { $html = $html.qq~ > $filename~; } $html = $html.qq~ |
Go Back to $SiteTitle
~; } ######################################################################################## sub PageNavigation { my($previd, $nextid, $html, $previndex, $nextindex); $previndex = $CategoryIndex - 1; $previd = $CategoryList[$previndex]->{CATID}; if($CategoryIndex == @CategoryList - 1) { $nextindex = 0; } else { $nextindex = $CategoryIndex + 1; } $nextid = $CategoryList[$nextindex]->{CATID}; my $PageNav = qq~| Prev $CategoryName $CategoryList[$previndex]->{NAME} | ~;
$width = "33%";
} else {
$width = "100%";
}
$PageNav = $PageNav.qq();
if($TotalPages >= $Page) {
$PageNav .= qq(Jump To Page: ); } else { $PageNav .= qq( | );
}
#####
if($Page > 1 && $TotalPages > 1) {
if($SearchLink) {
$PageNav = $PageNav."<< ";
} else {
$PageNav = $PageNav."<< ";
}
}
if($Page < 1) {
$PageNav = $PageNav."No Pages Exist!";
}
####
for($j = 1; $j <= $TotalPages; $j++) {
if($j == $Page) {
$PageNav = $PageNav."[".$j."]";
} else {
if($SearchLink) {
$PageNav = $PageNav."[".$j."]";
} else {
$PageNav = $PageNav."[".$j."]";
}
}
}
####
if($Page < $TotalPages) {
if($SearchLink) {
$PageNav = $PageNav." >>";
} else {
$PageNav = $PageNav." >>";
}
}
#####
$PageNav = $PageNav."";
if($cgi->param("searchterm") eq "") {
$PageNav = $PageNav.qq~ Next $CategoryName $CategoryList[$nextindex]->{NAME} | ~;
}
$PageNav = $PageNav."
| Previous $PrevName | ~;
$PageNav = $PageNav.qq(Thumbnails | ); $PageNav = $PageNav.qq~Next $NextName | ~;
$PageNav = $PageNav."
| $CategoryName Listing: |
| Sorry, no categories exist yet. | ||
~;
if($CategoryList[$counter]->{IMAGE} ne "") {
$catimg = qq~
| ";
if($catcount % 2 == 1){
$html = $html."
No pictures available | );
$html = $html.qq(
);
$html = $html.qq(
| \n);
$stop = 1;
} else {
$html = $html.qq(\n\n); $html = $html.ThumbHTML($Index); $html = $html.qq( | \n); } } $html = $html.qq(
| ); $ImageDisplayFormat = $ImageDisplayFormat.$ImageDisplay; $ImageDisplayFormat =~ s//$code/g; $ImageDisplayFormat =~ s//$DisplayName/g; $ImageDisplayFormat =~ s//$ShowData[$FILESIZE]/g; $ImageDisplayFormat =~ s//$ShowData[$TYPE]/g; if($ShowData[$DATE] ne "") { my $tempdate = NormalDateTime($ShowData[$DATE]); $ImageDisplayFormat =~ s//$tempdate/g; } if($ShowData[$COPYRIGHT] ne "") { $ImageDisplayFormat =~ s//$ShowData[$COPYRIGHT]/g; } if($ShowData[$AUTHOR] ne "") { $ImageDisplayFormat =~ s//$ShowData[$AUTHOR]/g; } $ImageDisplayFormat =~ s//$ShowData[$DOWNLOADS]/g; if($ShowData[$DESCRIPTION] ne "") { $ImageDisplayFormat =~ s//$ShowData[$DESCRIPTION]/g; } if($ShowData[$USER] ne "") { $ImageDisplayFormat =~ s//$ShowData[$USER]/g; } if($ShowData[$IP] ne "") { $ImageDisplayFormat =~ s//$ShowData[$IP]/g; } for(my $counter = 0; $counter < @MediaFormat; $counter++) { if($MediaFormat[$counter]->{KEYWORD} ne "") { $ImageDisplayFormat =~ s/$MediaFormat[$counter]->{KEYWORD}/$MediaList[$index][$counter]/g; } } $ImageDisplayFormat = $ImageDisplayFormat.qq( |