#!/usr/local/bin/perl
#################################################################
#
# + FtpLocate - FTP search engine
#
# by Distributed System Lab E.E. NCKU Taiwan 2000
# http://ftp.ee.ncku.edu.tw/ftplocate/
#
#################################################################

#if ( defined($ENV{'REMOTE_ADDR'}) ) { exit; }	# cgi not allowed

unshift(@INC, substr($0, 0, rindex($0,'/')) );	# add prog path to INC
require ("config");

if ( defined($ARGV[0]) ) {
  $site=$ARGV[0];
  $zero=sprintf($SETFPATTERN, 0);
  if ( ! -f "$FILELISTDIR/$site/$zero" ) {
    exit 1;
  }
} else {
  exit 1;
}

opendir(D, "$FILELISTDIR/$site"); 
while ($_=readdir(D)) {
  if ( /^\d+$/ ) { 
    push (@f, $_);
  }
}
closedir(D);

chdir("$FILELISTDIR/$site"); 

@f=sort { $a cmp $b } @f;
foreach $file (@f) {
  open(F, $file);
  while (<F>) {
    print $_;
  }
  close(F);
}

exit 0;
