#!/usr/bin/perl $discus_conf = '/home/moger/cgi_data/myscript/admin/discus.conf'; #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 = ; 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 "Script Execution Error\n"; print "\n"; print "

Script Execution Error

\n"; print "Discus scripts could not execute because the discus.conf file\n"; print "could not be opened."; print "

Reason: $!" if $!; print "

This generally indicates a setup error of some kind.\n"; if ($0 =~ m|\.(\w+)$|) { print "

Consult your diagnostics for details.\n"; } print "Consult the Discus "; print "Resource Center for troubleshooting information.\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 "

$titlex
\n"; print "
\n"; print "$L{ILINSTR}\n"; print "

\n"; print "

\n"; print "\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 ""; print ""; print "\n"; } } print "
$L{ILTAG}$L{ILIMAGE}
\$tag", "{$name}
\n"; print "


$L{ILBACK}"; print "

\n\n"; &ex('printuntil', 3, 17, 0, "", 0, 1); exit(0); # END - FILE IS CORRECTLY UPLOADED #