home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / GAPRAP13.ZIP / UPCHECK.BAT < prev   
DOS Batch File  |  1995-01-04  |  8KB  |  296 lines

  1. REM @Echo Off
  2. REM This file is extensively commented so you can see what's going on.
  3. REM These comments are parsed by DOS when executing this file and 
  4. REM will significantly slow down the UPCHECK processing.  If you're 
  5. REM going to use this UPCHECK.BAT, make a copy and delete all the REM
  6. REM statements and blank lines.
  7. REM
  8. REM This UPCHECK.BAT makes use of GAPECHO, a freebie utility written
  9. REM by Bob Naken for communicating with the user from batch files
  10. REM such as this one.  If you don't have GAPECHO, it should be 
  11. REM available from The Crow's Nest.
  12. REM
  13. REM It is IMPERATIVE(!!!) that you have environment variables defined
  14. REM for C_PORT and TEST_DIR.  C_PORT is the comm port in use on this 
  15. REM node.  
  16. REM 
  17. REM TEST_DIR is just a temp directory where archives can be unzipped 
  18. REM and scanned.  Any empty directory will do, but you MUST have one 
  19. REM defined.  The UPCHECK process will immediately abort if the TEST_DIR 
  20. REM does not exist.  You need to have the trailing '\' on the path.  The 
  21. REM SET statement in my autoexec.bat is:
  22. REM
  23. REM             SET TEST_DIR=C:\GAP\UP\WORK1\TEST\
  24. REM
  25. REM Be sure to create this directory before attempting to run this file.
  26. REM
  27. REM GAP passes the following parameters to this batch file.
  28. REM
  29. REM             %1  -  Full path and name of file
  30. REM             %2  -  Upload Directory path
  31. REM             %3  -  Filename
  32. REM             %4  -  Filename without the extension
  33. REM             %5  -  Extension without the filename
  34. REM             %6  -  0 = Remote Caller On, 1 = Sysop On Locally,
  35. REM                    2 = Local User
  36.  
  37. REM Initialize the variables used in UPCHECK.BAT
  38.  
  39.     set old_date=800101
  40.     set new_date=910101
  41.  
  42. REM Tell the user what we're doing
  43.  
  44.     GAPECHO %C_PORT%Testing Upload(s) for File Integrity...
  45.  
  46. REM Turn on HyperDisk Staged writes to speed up the check.
  47. REM (If you don't use HyperDisk, just eliminate this line.)
  48.  
  49.     hyperdk S OR 
  50.  
  51. REM Verify that the TEST_DIR actually exists 
  52.  
  53.     if ##%TEST_DIR% == ## goto Abort
  54.  
  55. REM Branch according to the file extension.
  56.  
  57.     If %5 == LZH Goto LZH
  58.     If %5 == GIF Goto GIF
  59.     If %5 == TXT Goto TXT
  60.     If %5 == DOC Goto TXT
  61.     If %5 == ZIP Goto ZIP
  62.     If %5 == ARJ Goto ARJ
  63.     If %5 == ARC Goto ARC
  64.     If %5 == EXE Goto EXE
  65.     If %5 == COM Goto EXE
  66.     If %5 == PAK Goto ARC
  67.     if %5 == ZOM Goto Nosupport
  68.     if %5 == DMS Goto Nosupport
  69.     if %5 == WRP Goto Nosupport
  70.     if %5 == LWP Goto Nosupport
  71.     if %5 == ZOO Goto Nosupport 
  72.     Goto Unknown
  73.  
  74.  
  75. REM  Process EXE files.
  76.  
  77. :EXE
  78.  
  79. REM Check for self extracting file.
  80.  
  81.     GAPECHO %C_PORT%#Checking for self-extracting file. Please wait...
  82.     Pkunzip -t %1
  83.     If Errorlevel 1 goto isLZH
  84.     Goto ZIP
  85.  
  86. :isLZH
  87.  
  88.     Lharc t /v %1
  89.     If Errorlevel 1 goto isARC
  90.     Goto LZH
  91.  
  92. :isARC
  93.  
  94.     pak t %1
  95.     If Errorlevel 1 goto isEXE
  96.     Goto ARC
  97.  
  98. :isEXE
  99.  
  100. REM The user has sent a regular .EXE file. (Bad user!)  Let's copy
  101. REM it to the TEST_DIR, scan it for viruses, and then ZIP it up.
  102.  
  103.     GAPECHO %C_PORT%##File is not self-extracting!  Next time please
  104.     GAPECHO %C_PORT%#Zip the file before sending.#
  105.     Copy %1 %TEST_DIR%
  106.     Scan /A %TEST_DIR%*.* /D /NOMEM
  107.     If Errorlevel 1 Goto Bad
  108.     GAPECHO %C_PORT%#No Viruses Detected.... Now Zipping File....
  109.     Pkzip %2\%4 %TEST_DIR%*.*
  110.     Erase %1 > nul
  111.     Goto Comment
  112.  
  113. REM Process ARC files
  114.         
  115. :ARC
  116.  
  117.     Pkunpak -t %1
  118.     If Errorlevel 1 Goto Bad
  119.     GAPECHO %C_PORT% File Integrity Ok#Now Checking for Viruses...
  120.     Pkunpak %1 %TEST_DIR%
  121.     scan /A %TEST_DIR%*.* /D /NOMEM
  122.     If Errorlevel 1 Goto Bad
  123.     GAPECHO %C_PORT%  No Viruses Detected#Now Checking File Dates...
  124.     GAPwRAP /f /r %TEST_DIR% %2 %old_date% %new_date%
  125.     if errorlevel 1 goto Too_Old
  126.  
  127. REM The contents of the ARC file are OK.  Let's ZIP them up and get
  128. REM rid of the original file.
  129.  
  130. :A_ZIP
  131.  
  132.     GAPECHO %C_PORT%  File dates OK#Converting to ZIP Archive...
  133.     Pkzip -m %2\%4 %TEST_DIR%*.*
  134.     Erase %1 > nul
  135.     GAPECHO %C_PORT%Files Converted#
  136.     Goto Comment
  137.  
  138. REM Process ZIP file
  139.  
  140. :ZIP
  141.  
  142.     Pkunzip -t %1 > Fail.Txt
  143.     If Errorlevel 1 Goto Bad
  144.     GAPECHO %C_PORT%  File Integrity Ok#Now Checking for Viruses...
  145.     Del Fail.Txt  > nul
  146.     Pkunzip -o %1 %TEST_DIR%
  147.     scan /A %TEST_DIR%*.* /D /NOMEM
  148.     If Errorlevel 1 Goto Bad
  149.     GAPECHO %C_PORT%  No Viruses Detected!#Now Checking File Dates...
  150.     GAPwRAP /f /r /d %TEST_DIR% %2 %old_date% %new_date%
  151.     if errorlevel 1 goto Too_Old
  152.     Goto Comment
  153.  
  154. REM Process ARJ file
  155.  
  156. :ARJ
  157.  
  158.     ARJ t %1 > Fail.Txt
  159.     If errorlevel 1 goto Bad
  160.     GAPECHO %C_PORT%  File Integrity OK#Now Checking for Viruses...
  161.     Del Fail.txt > nul
  162.     ARJ e %1 %TEST_DIR%
  163.     scan /A %TEST_DIR%*.* /D /NOMEM
  164.     If errorlevel 1 Goto Bad
  165.     GAPECHO %C_PORT%  No Viruses Detected#Now Checking File Dates...
  166.     GAPwRAP /f /r %TEST_DIR% %2 %old_date% %new_date%
  167.     if errorlevel 1 goto Too_Old
  168.  
  169. REM The contents of the ARJ file are OK.  Let's ZIP them up and get
  170. REM rid of the original file.
  171.  
  172. :ARJ_ZIP
  173.  
  174.     GAPECHO %C_PORT%Files Dates are OK#Converting to ZIP Archive...
  175.     Pkzip %2\%4 %TEST_DIR%*.*
  176.     Erase %1 > nul
  177.     GAPECHO %C_PORT%Files Converted#
  178.     Goto Comment
  179.  
  180. REM Process .TXT file
  181.  
  182. :TXT
  183.  
  184.     GAPECHO %C_PORT%#Thank You for the Text File!
  185.     Copy %1 %TEST_DIR%
  186.     Pkzip %2\%4 %TEST_DIR%*.*
  187.     Erase %1 > nul
  188.     GAPECHO %C_PORT%#Now Zipping file to save storage space.
  189.     GAPECHO %C_PORT%#Next time please Zip the file before sending.
  190.     Goto Comment
  191.  
  192. REM Choosy perverts choose GIF!
  193.  
  194. :GIF
  195.  
  196.     GAPECHO %C_PORT%#Thank You for the GIF File!
  197.     Goto Good
  198.  
  199. REM Process LZH file
  200.  
  201. :LZH
  202.  
  203.     Lharc t /v %1
  204.     If Errorlevel 1 Goto Bad
  205.     GAPECHO %C_PORT%  File Integrity Ok#Now Checking for Viruses...
  206.     Lharc x %1 %TEST_DIR%
  207.     scan /A %TEST_DIR%*.* /D /NOMEM
  208.     If Errorlevel 1 Goto Bad
  209.     GAPECHO %C_PORT%  No Viruses Detected#Now Checking File Dates...
  210.     GAPwRAP /f /r %TEST_DIR% %2 %old_date% %new_date%
  211.     if errorlevel 1 goto Too_Old
  212.     GAPECHO %C_PORT%  Files Dates are OK#Now Converting to ZIP Archive...
  213.  
  214. REM The contents of the LZH file are OK.  Let's ZIP them up and get
  215. REM rid of the original file.
  216.  
  217. :L_ZIP
  218.  
  219.     Pkzip %2\%4 %TEST_DIR%*.*
  220.     Erase %1 > nul
  221.     GAPECHO %C_PORT%  Files Converted#
  222.     Goto Comment
  223.  
  224. REM I don't know WHAT this thing is!
  225.  
  226. :Unknown
  227.  
  228.     Copy %1 l:\bad_ups
  229.     Del %1 > nul
  230.     GAPECHO %C_PORT%#I Don't Recognize This File Type!
  231.     GAPECHO %C_PORT%#The Sysop Will Examine It Before Posting for Download.
  232.     Goto End
  233.  
  234. REM The file failed one of the validity checks.  Send it to the 
  235. REM bad file graveyard and tell the user about it.
  236.  
  237. :Bad
  238.  
  239.     Copy %1 l:\bad_ups
  240.     Del %1 > nul
  241.     GAPECHO %C_PORT%#Errors Detected In This File!
  242.     GAPECHO %C_PORT%#Please Check Your Copy for Validity/Viruses!
  243.     Goto End
  244.  
  245. REM The file failed the date checks done by GAPwRAP.  Send it to the
  246. REM bad file graveyard and tell the user about it.
  247. REM You'll probably want to adjust this message to the date standards
  248. REM you want to enforce.
  249.  
  250. :Too_Old
  251.  
  252.     Copy %1 l:\bad_ups
  253.     Del %1 > nul
  254.     GAPECHO %C_PORT%#  Files Too Old!
  255.     GAPECHO %C_PORT%#All uploaded files must be less than two years old.
  256.     GAPECHO %C_PORT%#Moving file to offline area for review prior to posting.
  257.     Goto End
  258.  
  259. REM Add the BBS ad to the ZIP as a comment
  260.  
  261. :Comment
  262.  
  263.     Pkzip -z %2\%4 < c:\GAP\gen\zip.scr
  264.     Goto Good
  265.  
  266. REM It's a good file!
  267.  
  268. :Good
  269.  
  270.     GAPECHO %C_PORT%  File Passed Integrity/Virus Check!#
  271.  
  272. REM Files.lst is the "raw" file listing created by GAP_LIST that I use
  273. REM with HS/Link to check for duplicate uploads.  By echoing the name
  274. REM of the newly uploaded file to the end of files.lst, the list will
  275. REM be kept current at all times.
  276.  
  277.     echo %3 >> i:\gap\files\files.lst
  278.     Goto End
  279.  
  280. REM The user has uploaded a file that UPCHECK.BAT does not support.
  281.  
  282. :Nosupport
  283.  
  284.     GAPECHO %C_PORT%#Virus check not performed.  This file type is not 
  285.     GAPECHO %C_PORT%#supported by The Cookie Jar.
  286.     Goto End
  287.  
  288. :End
  289.  
  290. REM Go back to write-through HyperDisk caching.  Remove this line if you
  291. REM don't use HyperDisk.
  292.  
  293.     hyperdk W OR
  294.  
  295. :Abort
  296.