echo off
rem -- process test uploads request - for ProDOOR 3.0
rem -- %1-logfile, %2-testdir, %3-comport

rem -- keep a permanent copy of all DSZLOG transfer log files
rem if exist %DSZLOG% type %DSZLOG% }}L:\pcb\perm.log

rem -- exit quietly if no files were uploaded
if not exist %2\*.* goto end

rem -- convert unwanted .arc files to .zip format
if not exist %2\*.arc goto testzip

:convert
chkpath proecho %0 >>%1
if errorlevel 1 goto end
proecho %3 ~~Converting ARC files to ZIP format.  Please wait...~

rem -- I recommend you add ",*.ARC,999," to your UPSEC to lock out ARC
rem -- uploads if you are converting to ZIP.  If you accept ARC files
rem -- you should delete the next two commands

rem -- convert ARC files to ZIP files; TOZIP is from ZIPKIT43.ZIP or newer.
chkpath tozip %0 >>%1
if errorlevel 1 goto testzip
tozip %2\* >>%1

rem -- dsz's $door.log is no longer valid after conversion, delete it.
if exist %DSZLOG% del %DSZLOG%

:testzip
rem -- test zipfiles
proecho %3 ~~Testing uploads.  Please wait...~

rem -- check for truncated uploads; ZIPDS is from ZIPDS11.ZIP or newer
chkpath zipds %0 >>%1
zipds %2\* >>%1

rem -- finally use PKUNZIP to test for correct crcs in new files.
chkpath pkunzip %0 >>%1
pkunZIP -t %2\* >>%1
touch %2\*.zip

REM ********** FROM HERE DOWN WE DIFFER FROM THE STANDARD PROUTEST **********
REM ************ YOU SHOULD REMOVE THE REM LINES TO IMPROVE SPEED. **********

rem -- I have found that bad uploads sometimes get by prodoor with the
rem -- "write to log" method Sam uses.  I have added my own test using
rem -- the errorlevel that PKUNZIP produces, and move things offline
rem -- for manual testing later.  This is up to you, and has nothing to
rem -- do with the function of TESTAGE.EXE.
if errorlevel 1 goto badupload

proecho %3 All the .ZIP's look ok, let's take a look at~
proecho %3 what's inside.  First, I need to get rid of~
proecho %3 ZIP comments, then check the program's age.~

rem -- recom.exe (from recom105.zip) strips (or adds, modifies etc..)
rem -- comments from the .ZIP files, and sets the date of the .ZIP to
rem -- the date of the most recent file in the archive.
recom -o %2\*.ZIP

proecho %3 ~ZIP comments have been removed, lets see~
proecho %3 how old the files in the .ZIP are...~~

rem -- testage now checks against the year parameter you pass it, and
rem -- moves the program to the "holding" directory if older than the
rem -- year you specified.  It also returns an errorlevel so you can
rem -- let the user know why the file was rejected.
testage %2 1988 d:\hold

if errorlevel 1 goto baddates
goto end

:baddates
proecho %3 At least one of the programs you uploaded is~
proecho %3 more than 2 years old.  I will move any old~
proecho %3 programs offline for evaluation by the sysop.~
proecho %3 ~Please do not upload items over 2 years old.~
goto end

:badupload
proecho %3 Looks like one or more uploads are no good...~
proecho %3 I will move all file(s) you just uploaded~
proecho %3 offline for manual evaluation by the sysop.~
copy %2\*.* d:\hold
del %2\*.ZIP

:end
