--[ Intro ]----------------------------------------------

 Tur-PreCheck. A script to only allow certain types 
 of files to be uploaded. This has nothing to do with 
 directories. Only files.

 It can also be used ONLY to ban certain files from being
 uploaded, as well as enforce that nobody uploads a .sfv and/or
 into a dir where there already is one.

 Oh, and it can also block those nasty double nfos called blabla(18).nfo
 which have been dubbed ftprushnfos (rename instead of skip in 'if exists' rules).

 It also works as a replacement for zipscript-c's 
 precheck.sh if you want it to.

--[ Install ]--------------------------------------------
 
 Copy tur-predircheck.sh to /glftpd/bin. Set 755 on it. 

 Required binaries that must be in your /glftpd/bin dir:
 echo, cut, tr, egrep, grep & basename

 Change the options in the script: 

 -------------------------------------------------------------------------------

 zipdatadir = If you are using zipscript-c, you'll want to set this to the
  zipscript dir. Usually: /ftp-data/zipscript

  If you use pzs-ng's zipscript-c, the default path is /ftp-data/pzs-ng

  If you do NOT use zipscript-c, you  MUST  set this to ""

  If you do use zipscript-c however, this script does the same thing its
  predircheck.sh does. Its even a cut and paste from it =) Keep reading.

 -------------------------------------------------------------------------------

 ALLOWED = Which filetypes to allow. Its a standard egrep line, part from 
  using spaces to seperate instead of |. 
  ( You can use | here instead of spaces if it makes you feel better. )
 
  . = Any char, so if you want to specify a "real" . use \.
  Any non alpha chars (alpha: a-z 0-9) should be escaped with a \
 
  ^ forces start of word. $ forces end of word, 
  ie \.nfo would hit on rel.nfo.fix whereas \.nfo$ would ONLY hit if the rel 
  ends with .nfo 

  Likewise, ^file\.nfo$ would only hit if the exact filename is file.nfo 
 
  \.r[a0-9][r0-9]$ = Any file ending with .rar or .r01 (any 2 char number). 
 
  It is NOT case sensitive, so dont need \.r[aA0-9]$ 
 
  "" = Dont check allowed files. All is good.

  NOTE: If you do not understand this syntax, despite the info I gave above
  then you should probably not play with this script !!

 -------------------------------------------------------------------------------
 
 BANNED = A reversed ALLOWED. While you allow .nfo above, you might want to NOT 
  allow, for instance, aks.nfo, which is a site nfo. 
 
  Same rules apply here as for ALLOWED, but you really only need to add files with 
  extensions that is added in ALLOWED, or it wont be ok anyway (ie, dont need \.imdb$
  here since \.imdb$ isnt in the ALLOWED part anyway. 
 
  BANNED has higher prio then ALLOWED, so if you add \.nfo$ as banned, no
  nfos will be allowed.
 
  "" = Disable checking for banned files. 
 
  NOTE: I added LOTS of sitenfos here that I had in my skipl.. err got from a pal. 
  Keep them there if you like or do your own list. It does not get slower just
  cause you add more files here.
 
 -------------------------------------------------------------------------------

 NODOUBLESFV = TRUE/FALSE. If the user tries to upload a sfv, check that there isnt
  one in the dir already. If so, dont allow it.

  If you want to announce this in irc and embarras the user, there is support for
  this too, with dZSbot.tcl.
  If you want this, set GLLOG to your glftpd.log file. If you do NOT want announce,
  set GLLOG=""

  If you do not run dZSbot.tcl and want announce, you need to modify the TURGEN
  line to suit your current botscript (search for TURGEN).

  I use TURGEN in other scripts, so if you already added it to dZSbot.tcl, you dont
  need to do this again. Otherwise:

  Do the following in dZSbot.tcl and rehash the bot.
  To 'set msgtypes(DEFAULT)', add TURGEN

  Add the following in the appropriate places:
  set chanlist(TURGEN)  "#YourChan"
  set disable(TURGEN)   0
  set variables(TURGEN) "%msg"
  set announce(TURGEN)  "%msg"

  If you use the pzs-ng bot, instead of set announce(TURGEN), you add
  announce.TURGEN = "%msg"
  in your themefile.
 
  Some notes on this:
  In the TURGEN line, if you plan to change the output, you'll see ^B and ^_
  Those are control codes for bold and underscore. You can NOT just type that
  and expect it to be bold. You need to use vi. ctrl-b is bold and ctrl-_ is 
  underscore.

  -------------------------------------------------------------------------------

 NOSAMENAME = TRUE/FALSE. If a user tries to upload, for example, test.rar when
  TEST.rar is already there, he will be denied. This is to prevent cataclysmic
  events which sometimes takes place when files are preed with different case
  structures on the files.

  Settings this to FALSE will skip this verification test.

 -------------------------------------------------------------------------------

 NODOUBLENFO = TRUE/FALSE. Same usage as NODOUBLESFV, but for .nfo files.

 -------------------------------------------------------------------------------

 NOFTPRUSHNFOS = TRUE/FALSE. Some ftp clients *ftprush*cough*cough* has a setting
                 called 'rename' in the 'if file exists' rules. When this is
                 enabled it will rename the nfo if it already exists.
                 This creates those multiple blabla(18).nfo files you've seen.
                 Setting this to true will disallow upload of a nfo file that
                 looks like that. Ie: (0-100).nfo.

                 Yes, you can use this as well as NODOUBLENFO to make sure you
                 get the correct nfo, without the (number).nfo

 -------------------------------------------------------------------------------

 EXCLUDEDDIRS = Which dirs not to care in. This can be any part of the full path. 
  If you add, for instance, just the word DIVX here, any release containing DIVX
  will be okey to upload any files into. Therefor, add /DIVX instead, or even
  /DIVX/
 
  NOTE: If the dir in question is added as a 'nodupecheck' dir in glftpd.conf, it 
  will NOT run there at all. Thats good but dont know if that is intentional by the gl 
  coders. Better add the PRE dirs here anyway incase that functionality changes.

 -------------------------------------------------------------------------------

 ERROR1 = What to say incase the file is not in the allowed list. 

 ERROR2 = What to say incase the file is banned. 

 ERROR3 = What to say in glftpd if there is already a .sfv in the dir.

 ERROR4 = What to say if there is already a file with a different case structure
          in this dir (Ie, test.rar is there. User tries to upload Test.rar).

 ERROR5 = What to say in glftpd if there is already a .nfo in the dir.

 ERROR6 = What to say in glftpd if the NOFTPRUSHNFOS are set to TRUE and it
          hits one of those annoying files.
 
 -------------------------------------------------------------------------------

 Test if from shell: 
 chroot /glftpd 
 cd /bin 
 ./tur-precheck.sh "filename.nfo" /some/fake/path 
 
 If it just quits, it ok. If it gives error, it wouldnt have allowed that file to uploaded from glftpd. 
 If it gives a "no such command" error, you are missing the binary it complains about in /glftpd/bin.
 
 Now we need to load it as a pre_check script in glftpd.conf. Simply add:
 pre_check /bin/tur-precheck.sh 
 
 IMPORTANT: If you use zipscript-c, you probably already have a precheck in glftpd.conf. 
 If so, remove that precheck and add the one for this script instead!


--[ ALL DONE ]--------------------------------------------
