#!/usr/local/bin/perl
$discus_conf = '/home/localhost/usr/local/share/apache/htdocs/ustelestar/discus/discus_admin_5998910083/discus.conf';
$pro_fileid = '256231955560';
$pro_license = '0011-2903-2914';
#Discus board image lister script
#-------------------------------------------------------------------------------
# DISCUS VERSION 3.10 COPYRIGHT NOTICE
#
# Discus 3.10 is copyright (c) 2000 by DiscusWare, LLC, all rights reserved.
# The use of Discus is governed by the Discus License Agreement which is
# available from the Discus WWW site at:
#    http://www.discusware.com/discus/license
#
# Pursuant to the Discus License Agreement, this copyright notice may not be
# removed or altered in any way.
#-------------------------------------------------------------------------------
#
# This script takes some arguments that will help webmasters customize the image
# displays.  These arguments are as follows:
#
# tagname=_____
#    Instead of \clipart{}, the script will tell user to use the specified tagname
#
# dir=____
#    Specify a directory other than "clipart" to search.  You can use only
#    alphanumeric characters (no .. to protect your security), you can search only
#    subdirectories of your HTML directory ($html_dir), and you can't search
#    "messages" (again, for security).
#
# filterbegin=____
#    Filter images displayed by showing only those images whose file names START
#    with the filter you have specified here.
#
# filterend=___
#    Filter images displayed by showing only those images whose file names END
#    with the filter you have specified here.  Extensions DO NOT COUNT when
#    considering the filter!
#
# title=____
#    Specify an alternate title for the search
#
# show=___ (,___,___)
#    Choose specific files to show
if (open (FILE, "$discus_conf")) {
	@file = <FILE>;
	close (FILE);
	foreach $line (@file) {
		if ($line =~ /^(\w+)=(.*)/) {
			$varname = $1;
			$value = $2;
			$value =~ s/\r//g;
			${$varname} = $value;
		}
	}
	require "$admin_dir/source/src-board-subs-common";
} else {
	print "Content-type: text/html\n\n";
	print "<HTML><HEAD><TITLE>Script Execution Error</TITLE></HEAD>\n";
	print "<BODY BGCOLOR=#ffffff TEXT=#000000>\n";
	print "<H1>Script Execution Error</H1>\n";
	print "Discus scripts could not execute because the discus.conf file\n";
	print "could not be opened.";
	print "<P>Reason: <FONT COLOR=#ff0000><B>$!</B></FONT>" if $!;
	print "<P>This generally indicates a setup error of some kind.\n";
	if ($0 =~ m|\.(\w+)$|) { print "<p>Consult your <a href=diagnose.$1>diagnostics</a> for details.\n"; }
	print "Consult the <A HREF=\"http://www.discusware.com/support\">Discus ";
	print "Resource Center</A> for troubleshooting information.</BODY></HTML>\n";
	exit(0);
}
&parse_form;
$titlej = $title;
$titlej =~ s/['"<>]//g; #Not friendly characters for our JavaScript!
$acceptable_images = 'gif';
if ($FORM{'dir'} ne "") {
	$dir = $FORM{'dir'};
	$dir =~ s/\W//g;
	if ($dir eq "" || $dir eq "messages") {
		&error_message("Directory Search Error", "Directory [$FORM{'dir'}] cannot be searched!", 0, 1, 1);
	}
	if (!-e "$html_dir/$dir") {
		&error_message("Directory Search Error", "Directory [$FORM{'dir'}] does not exist!", 0, 1, 1);
	}
	if (!-d "$html_dir/$dir") {
		&error_message("Directory Search Error", "Directory [$FORM{'dir'}] is not a directory!", 0, 1, 1);
	}
	$image_directory = "$html_dir/$dir";
	$image_url = "$html_url/$dir";
} else {
	$image_directory = "$html_dir/clipart";
	$image_url = "$html_url/clipart";
}
if ($FORM{'tagname'} ne "") {
	$tag = $FORM{'tagname'};
	$tag =~ s/<([^>]+)>//g;
	&error_message("Illegal Tag", "Cannot use tag [$tag]!", 0, 1, 1) if $tag eq "";
} else {
	$tag = $L{ILCLIPTAG};
}
if ($FORM{'filterbegin'} ne "") {
	$fb = quotemeta($FORM{'filterbegin'});
}
if ($FORM{'filterend'} ne "") {
	$fe = quotemeta($FORM{'filterend'});
}
if ($FORM{'show'} ne "") {
	@files = split(/,/, $FORM{'show'});
	foreach $file (@files) {
		$shown{$file} = 1;
	}
}
if ($FORM{'title'} ne "") {
	$titlex = $FORM{'title'};
	$titlex =~ s/<([^>]+)>//g;
} else {
	$titlex = $L{ILTITLE};
}
&header;
&ex('printuntil', 1, 1, 0, "$titlex");
($bgcolor, $text, $link, $vlink, $alink, $font, $size, $img) = &extract_colorsonly;
print "<CENTER><FONT SIZE=+1><B>$titlex</B></FONT></CENTER>\n";
print "<HR>\n";
print "$L{ILINSTR}\n";
print "<P>\n";
print "<P><TABLE BORDER=1>\n";
print "<TR><TD><B><FONT FACE=\"$face\">$L{ILTAG}</FONT></B></TD><TD><B><FONT FACE=\"$face\">$L{ILIMAGE}</FONT></B></TD></TR>\n";
undef @files;
opendir(IMAGES, $image_directory);
while ($name = readdir(IMAGES)) {
	next if $fb ne "" && $name !~ m|^$fb|i;
	if ($name =~ m|\.$acceptable_images$|) {
		$filename = $`;
		next if $fe ne "" && $filename !~ m|$fe$|i;
		next if ($FORM{'show'} ne "" && $shown{$filename} == 0);
		push (@files, $name);
	}
}
closedir(IMAGES);
foreach $file (sort(@files)) {
	$_ = $file;
	/\/?([^\/]*$)/;
	$_ = $1;
	$filename = $_;
	/(.*)\.(.*)/;
	$name = $1;
	$type = $2;
	if ($type =~ $acceptable_images && $filename !~ /your_image.gif/ && $filename !~ /board_logo.gif/ && $filename !~ /poweredby.gif/) {
		print "<TR>";
		print "<TD><FONT FACE=\"$face\" SIZE=\"$size\"><B>&#92;$tag", "{</B>$name<B>}</B></FONT></TD>";
		print "<TD><IMG SRC=\"$image_url/$filename\"></TD></TR>\n";
	}
}
print "</TABLE>\n";
print "<HR><CENTER><A HREF=\"javascript:history.back()\">$L{ILBACK}";
print "</A></CENTER><P>\n\n";
&ex('printuntil', 3, 17, 0, "", 0, 1);
exit(0);
# END - FILE IS CORRECTLY UPLOADED #

