home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / HATCH / PBFILE21.ZIP / SPV-053J.MOD < prev   
Text File  |  1996-01-07  |  16KB  |  483 lines

  1. ┌────────────────────────────A CEREBRUM release!─────────────────────────────┐
  2. │ Mod Name: SPV-053J.MOD     Mod Authors: Pâpâ ßêâr (11579.wwivnet)          │
  3. │ Difficulty: ▓░░░░░░░░░     First ----- [11/18/94]                          │
  4. │ WWIV Version: 4.24/a       Last ------ [01/07/96]                          │
  5. │ Files Affected: MMENU.C FCNS.H                                             │
  6. │ Description: Allows registered users of PBFILES to include into their      │
  7. │source a way for their users to download a CURRENT file listing for whatever│
  8. │directory they're in.  Lets them choose file mask, date limiting, MORE!     │
  9. │ Now you do lists by dir, conference, N-Scan, or entire xfer section!       │
  10. │ Now with menuing system -- more control, change your choices!              │
  11. ╞═────────────────────────────────────═╤═───────────────────────────────────═╡
  12. │ StarPort Valhalla [   ]   -     ASV 28.8kbps  Home of the SPV mod series!  │
  13. └─────────────────────────────────────═╧═────────────────────────────────────┘
  14.  Word of Warning:  You installed it, you're responsible! Make back-ups BEFORE
  15.  attempting to install this modification!  Read all text before beginning.
  16. ─────────────────────────────────────────────────────────────────────────────
  17.  LEGEND:
  18.  ==  Original Code [use this to search on]
  19.  ++  Add this Line [mods ALWAYS add stuff, don't they?]
  20. ─────────────────────────────────────────────────────────────────────────────
  21.  LONG DESCRIPTION: This is a great way for your users to get THE most current
  22. listing of files from your BBS!  The only thing you need to do is install
  23. this mod (a simple block copy), and register PBFILES.
  24.  It will allow the users to toggle WWIV color codes, high ASCII character
  25. inclusion, extended descriptions, and long file information.  It will also
  26. allow them to limit files both by file date and file mask.
  27.  
  28.                        >>>  NOTE! NOTE! NOTE! NOTE! <<<
  29. Because PBFILES in its unregistered mode asks you to press a random key upon
  30. running the program, this modification should *NOT* be used with an
  31. unregistered copy, or it'll lock up your board until you (on the local side)
  32. can press the key!
  33.  
  34. Revision "H"
  35. o Revised to work with WWIV version 4.24+
  36.  
  37. Revision "I":
  38. o Fixed a small part that was reading the configuration file incorrectly.
  39.  
  40. Revision "J":
  41. o Added support for the ! command (ignore listing CD-ROM dirs).
  42.  
  43. To upgrade, replace the function void DownloadList(void)
  44. ─────────────────────────────────────────────────────────────────────────────
  45. STEP 0: Add these variable declarations in MMENU.C, void dlmainmenu(void)
  46.  
  47. ==  int i,i1,i2,abort,useconf,ac;
  48. ==  int dlredraw = 1;
  49. ==  static int ripdlg = 3;
  50. ++  char pbf[81],pbf1[81],pbf2[81],pbf3[81],pbf4[81];             // SPV-053
  51. ++  int i3;                                                       // SPV-053
  52. ==
  53. ==  s2[0]=0;
  54. ==  if (udir[curdir].subnum==-1) {
  55. ─────────────────────────────────────────────────────────────────────────────
  56. STEP 1: Open up MMENU.C, and block copy in this code in the function:
  57.         void dlmainmenu(void);
  58.  
  59. ==  /* Anyone commands here */
  60. ==  if (strcmp(s,"WHO")==0) {
  61. ==    multi_instance();
  62. ==  }
  63. // START SPV-053 BLOCK COPY
  64.   if (strcmp(s,"DLIST")==0) {
  65.     sprintf(s1,"<*> %s ran DLIST! -- Check PBFILES.LOG!",thisuser.name);
  66.     ssm(1,0,s1);
  67.     sysoplog(s1);
  68.     nl();
  69.     if (!exist("PBFILES.EXE")) {
  70.       if (so())
  71.         pl("6You need to place PBFILES.EXE in your main BBS directory!0");
  72.       else {
  73.         pl("6The program needed to generate the listing is not online!0");
  74.         ssm(1,0,"6PBFILES.EXE is missing from main BBS directory!0");
  75.       }
  76.       nl();
  77.     } else
  78.       DownloadList();
  79.   }
  80. // END SPV-053 BLOCK COPY
  81. ==
  82. ==  /* download cosysop checks here */
  83. ==  if (dcs()) {
  84. ─────────────────────────────────────────────────────────────────────────────
  85. STEP 2: Add these four entire functions to the end of MMENU.C
  86.  
  87. // SPV-053 START
  88. #define INCLUSION   "PBFILES.INC"                                   // NOTE 1
  89. #define BBSEXT      "SPV"                                           // NOTE 2
  90. #define DEFAULT     "STARPORT"                                      // NOTE 3
  91. #define DEFAULTMODE 2                                               // NOTE 5
  92.  
  93. void DownloadList(void)
  94. {
  95.   int Color,ASCII,More,Format,Extended,GIF,ok,i,i1[5],FileAge;
  96.   char ArchiveName[13],MaskName[13],InclusionName[13],s[81],ch,ch1,
  97.        pbf[81],OutFile[81],ConfLine[20][81],date[81],s1[81];
  98.   unsigned char Ignore=0;
  99.   FILE *ConfigFile;
  100.   time_t Time;
  101.   struct tm *TimePointer;
  102.  
  103.   Format=DEFAULTMODE;
  104.   if ((ConfigFile=fsh_open("PBFILES.INI","rt"))==NULL) {
  105.     sprintf(s,"6Could not read PBFILES.INI!0");
  106.     nl();
  107.     if (so())
  108.       pl(s);
  109.     else {
  110.       ssm(1,0,s);
  111.       pl("6PBfiles is currently offline, SysOp has been notified!0");
  112.     }
  113.     nl();
  114.     return;
  115.   } else {
  116.     i=-1;
  117.     while (!feof(ConfigFile))
  118.       fgets(ConfLine[++i],80,ConfigFile);
  119.     fclose(ConfigFile);
  120.     if (atoi(ConfLine[0])!=1030) {
  121.       sprintf(s,"6You need a NEW PBFILES.INI file -- run PBFILES /C!0");
  122.       unlink("PBFILES.INI");
  123.       nl();
  124.       if (so())
  125.         pl(s);
  126.       else {
  127.         ssm(1,0,s);
  128.         pl("6PBfiles is currently offline, SysOp has been notified!0");
  129.       }
  130.       nl();
  131.       return;
  132.     }
  133.     i1[0]=ASCII=atoi(ConfLine[13]);
  134.     i1[1]=Color=atoi(ConfLine[14]);
  135.     i1[2]=Extended=atoi(ConfLine[15]);
  136.     i1[3]=More=atoi(ConfLine[16]);
  137.     i1[4]=GIF=atoi(ConfLine[19]);
  138.   }
  139.   FileAge=i=date[0]=0;
  140.   sprintf(ArchiveName,DEFAULT);
  141.   strcpy(MaskName,"*.*");
  142.   do {
  143.     ok=0;
  144.     outchr(12);
  145.     sprintf(s,"1%s's 5PBFILES control center0",syscfg.systemname);
  146.     npr("%s",CenterText(s));
  147.     nln(2);
  148.     strcpy(s,"3The current settings are2:0");
  149.     npr("%s",CenterText(s));
  150.     nln(2);
  151.     strcpy(InclusionName,"PBFILES.$$");
  152.     switch (Format) {
  153.       case 0:
  154.         strcpy(s,"9This directory only0");
  155.         sprintf(InclusionName,":%s",
  156.                 directories[udir[curdir].subnum].filename);
  157.         break;
  158.       case 1:
  159.         strcpy(s,"9All directories 0- 1this conference0");
  160.         break;
  161.       case 2:
  162.         strcpy(s,"9All directories 0- 1entire BBS0");
  163.         strcpy(InclusionName,INCLUSION);
  164.         break;
  165.       case 3:
  166.         strcpy(s,"9All directories 0- 1N-Scan0");
  167.         break;
  168.     }
  169.     npr("4A0) 5Directories to process    0: %s\n\r0",s);
  170.     npr("4B0) 5File Mask being used      0: 9%s\n\r0",MaskName);
  171.     if (!FileAge)
  172.       strcpy(s,"6No age limitation0");
  173.     else
  174.       sprintf(s,"9Files 1%d9 days old and newer0",FileAge);
  175.     npr("4C0) 5Age limitation (days old) 0: 9%s %s\n\r0",
  176.          s,(date[0])?date:"");
  177.     npr("4D0) 5Strip high/low ASCII?     0: 9%s\n\r0",
  178.          (ASCII)?"YES":"NO");
  179.     npr("4E0) 5Include WWIV color?       0: 9%s\n\r0",
  180.          (Color)?"YES":"NO");
  181.     npr("4F0) 5Add long file information?0: 9%s\n\r0",
  182.          (More)?"YES":"NO");
  183.     npr("4G0) 5Include GIF resolutions?  0: 9%s\n\r0",
  184.          (GIF)?"YES":"NO");
  185.     npr("4H0) 5Download filename         0: 9%s.%s\n\r0",
  186.          ArchiveName,syscfg.arcs[0].extension);
  187.     npr("4I0) 5Include CD dirs in list?  0: 9%s\n\r0",
  188.          (Ignore)?"NO":"YES");
  189.     if (!Format)
  190.       npr("4J0) 5Add extended description? 0: 9%s\n\r0",
  191.            (Extended)?"YES":"NO");
  192.     nl();
  193.     pl("5P0) 1Create file list. (5ENTER1)0");
  194.     pl("6X0) 2Exit.0");
  195.     nl();
  196.     npr("3>0");
  197.     mpl(1);
  198.     if (!Format)
  199.       ch=onek("ABCDEFGHIJPX\r");
  200.     else
  201.       ch=onek("ABCDEFGHIPX\r");
  202.     nl();
  203.     switch (ch) {
  204.       case 'A':
  205.         if (thisuser.sysstatus & sysstatus_conference) {
  206.           npr("5Process by (1A5)ll dirs, (1C5)onference, 0");
  207.           npr("5(1N5)-Scan, or (1T5)his directory2: 0");
  208.           ch1=onek("ACTN");
  209.         } else {
  210.           npr("5Process by (1A5)ll dirs, (1N5)-Scan, 0");
  211.           npr("5or (1T5)his directory2: 0");
  212.           ch1=onek("ATN");
  213.         }
  214.         switch (ch1) {
  215.           case 'T':
  216.             Format=0;
  217.             break;
  218.           case 'C':
  219.             Format=1;
  220.             break;
  221.           case 'A':
  222.             Format=2;
  223.             break;
  224.           case 'N':
  225.             Format=3;
  226.             break;
  227.         }
  228.         break;
  229.       case 'B':
  230.         npr("5Enter file mask (1ENTER for *.*5)2: 0");
  231.         mpl(12);
  232.         input(s,12);
  233.         if (!s[0])
  234.           break;
  235.         strcpy(MaskName,s);
  236.         break;
  237.       case 'C':
  238.         npr("5Age limitation, in days (1N for last call date5)2: 0");
  239.         mpl(3);
  240.         input(s,3);
  241.         if (!s[0])
  242.           break;
  243.         if (s[0]=='N') {
  244.           time(&Time);
  245.           TimePointer=localtime(&Time);
  246.           strftime(s1,9,"%m/%d/%y",TimePointer);
  247.           FileAge=(int)((date_to_daten(s1)-
  248.                          date_to_daten(thisuser.laston))/86400L);
  249.           if (FileAge<1)
  250.             FileAge=1;
  251.           strcpy(date,"(Last call date)");
  252.         } else {
  253.           FileAge=atoi(s);
  254.           date[0]=0;
  255.         }
  256.         break;
  257.       case 'D':
  258.         ASCII^=1;
  259.         break;
  260.       case 'E':
  261.         Color^=1;
  262.         break;
  263.       case 'F':
  264.         More^=1;
  265.         break;
  266.       case 'G':
  267.         GIF^=1;
  268.         break;
  269.       case 'H':
  270.         npr("5Download filename (1no extension5)2: 0");
  271.         mpl(8);
  272.         input(s,8);
  273.         if (!s[0])
  274.           break;
  275.         sprintf(ArchiveName,"%s",s);
  276.         break;
  277.       case 'I':
  278.         Ignore^=1;
  279.         break;
  280.       case 'J':
  281.         Extended^=1;
  282.         break;
  283.       case '\r':
  284.       case 'P':
  285.         create_chain_file();
  286.         if (Format==1) {
  287.           if (!CreateConfList())
  288.             return;
  289.         } else if (Format==3) {
  290.           if (!CreateNscanList())
  291.             return;
  292.         }
  293.         ok=1;
  294.         sprintf(OutFile,"%s\%s.%s",syscfgovr.tempdir,
  295.                 directories[udir[curdir].subnum].filename,
  296.                 BBSEXT);
  297.         sprintf(pbf,"PBFILES /.%d /2 /I%s /O%s /B /K%s ",
  298.                     instance,InclusionName,OutFile,MaskName);
  299.         if (Ignore)
  300.           strcat(pbf,"/! ");
  301.         if (i1[0]!=ASCII)
  302.           strcat(pbf,"/H ");
  303.         if (i1[1]!=Color)
  304.           strcat(pbf,"/W ");
  305.         if (i1[3]!=More)
  306.           strcat(pbf,"/M ");
  307.         if (i1[2]!=Extended)
  308.           strcat(pbf,"/E ");
  309.         if (i1[4]!=GIF)
  310.           strcat(pbf,"/G ");
  311.         if (FileAge) {
  312.           sprintf(s,"/N%d ",FileAge);
  313.           strcat(pbf,s);
  314.         }
  315.         if (exist("DEBUG.XXX")) {
  316.           if ((ConfigFile=fopen("PBFILES.LOG","at"))!=NULL) {
  317.             fprintf(ConfigFile,"\n\nDEBUG: Command line from %s\n",
  318.                     syscfg.systemname);
  319.             fprintf(ConfigFile,"%s\n",pbf);
  320.             fclose(ConfigFile);
  321.           }
  322.         }
  323.         extern_prog(pbf,EFLAG_SHRINK|EFLAG_ABORT|EFLAG_TOPSCREEN);
  324.         if (!(thisuser.exempt & exempt_ratio)) {
  325.           thisuser.exempt+=exempt_ratio;
  326.           i=1;
  327.         }
  328.         nln(2);
  329.       pl("6<2***6> 3Please be patient, building file! 6<2***6>0");
  330.         pl("6DO NOT drop carrier.  This can take a few minutes!0");
  331.         nln(2);
  332.         add_arc(ArchiveName,OutFile,0);
  333.         download_temp_arc(ArchiveName,0);
  334.         remove_from_temp("*.*", syscfgovr.tempdir, 0);
  335.         if (i)
  336.           thisuser.exempt-=exempt_ratio;
  337.         unlink("PBFILES.$$");
  338.         break;
  339.       case 'X':
  340.         ok=1;
  341.         break;
  342.     }
  343.   } while ((!ok) && (!hangup));
  344. }
  345.  
  346. int CreateConfList(void)
  347. {
  348.   int ok,i;
  349.   unsigned int num,ns;
  350.   char s[120];
  351.   confrec *ConferencePointer,Conference;
  352.   directoryrec DirInfo;
  353.   FILE *pbfile;
  354.  
  355.   if ((pbfile=fsh_open("PBFILES.$$","wt"))==NULL) {
  356.     nl();
  357.     pl("6Can't create TEMP file, try the T, A, or N option instead.0");
  358.     nl();
  359.     return(0);
  360.   }
  361.   if (get_conf_info(2,&num,&ConferencePointer,NULL,&ns, NULL))
  362.     return(0);
  363.   Conference=ConferencePointer[curconfdir];
  364.   for (i=0;(i<ns) && (!hangup);i++) {
  365.     checkhangup();
  366.     DirInfo=directories[i];
  367.     if ((in_conference(i,&Conference))>-1) {
  368.       ok=1;
  369.       if (!DirInfo.name[0])
  370.         break;
  371.       if (thisuser.dsl<DirInfo.dsl)
  372.         ok=0;
  373.       if (thisuser.age<DirInfo.age)
  374.         ok=0;
  375.       if (DirInfo.dar>0) {
  376.         if ((thisuser.dar & DirInfo.dar)==0)
  377.           ok=0;
  378.       }
  379.       if (ok)
  380.         fprintf(pbfile,"%s\n",DirInfo.filename);
  381.     }
  382.   }
  383.   fsh_close(pbfile);
  384.   return(1);
  385. }
  386.  
  387. int CreateNscanList(void)
  388. {
  389.   FILE *pbfile;
  390.   int i,ac,ok;
  391.   directoryrec DirInfo;
  392.  
  393.   if ((pbfile=fsh_open("PBFILES.$$","wt"))==NULL) {
  394.     nl();
  395.     pl("6Can't create TEMP file, try the T, A, or C option instead.0");
  396.     nl();
  397.     return(0);
  398.   }
  399.   if ((uconfdir[1].confnum!=-1) && (okconf(&thisuser))) {
  400.     ac=1;
  401.     tmp_disable_conf(1);
  402.   }
  403.   for (i=0;(i<num_dirs) && (!hangup); i++) {
  404.     checkhangup();
  405.     DirInfo=directories[i];
  406.     ok=1;
  407.     if (!(qsc_n[i/32]&(1L<<(i%32))))
  408.       ok=0;
  409.     if (thisuser.dsl<DirInfo.dsl)
  410.       ok=0;
  411.     if (thisuser.age<DirInfo.age)
  412.       ok=0;
  413.     if (DirInfo.dar>0) {
  414.       if ((thisuser.dar & DirInfo.dar)==0)
  415.         ok=0;
  416.     }
  417.     if (ok)
  418.       fprintf(pbfile,"%s\n",DirInfo.filename);
  419.   }
  420.   fsh_close(pbfile);
  421.   if (ac)
  422.     tmp_disable_conf(0);
  423.   return(1);
  424. }
  425.  
  426. char *CenterText(char *String)
  427. {
  428.   int i,j;
  429.   char s[41],s1[81];
  430.  
  431.   j=40-((strlen(stripcolors(String))/2));
  432.   strcpy(s,"");
  433.   for (i=0;i<j;i++)
  434.     strcat(s," ");
  435.   sprintf(s1,"%s%s",s,String);
  436.   return(s1);
  437. }
  438. // SPV-053 END
  439.  
  440. NOTE 1: This is the filename of your *normally* used inclusion file for all
  441.         files.
  442.  
  443. NOTE 2: This is the extension you want to use for the file listing (inside
  444.         the ZIP file).
  445.  
  446. NOTE 3: This is the default ZIP file name.
  447.  
  448. NOTE 5: This is the default scanning mode:
  449.         0 = Current directory
  450.         1 = All directories in current conference
  451.         2 = All directories in BBS (as defined by normally used .INC file)
  452.         3 = All directories in N-Scan (set in transfer defaults)
  453. ─────────────────────────────────────────────────────────────────────────────
  454. STEP 3: Prototype the function in FCNS.H
  455.  
  456. == /* File: mmenu.c */
  457. ==
  458. == void mainmenu(void);
  459. == void dlmainmenu(void);
  460. ++ int CreateConfList(void);                                      // SPV-053
  461. ++ void DownloadList(void);                                       // SPV-053
  462. ++ char *CenterText(char *String);                                // SPV-053
  463. ++ int CreateNscanList(void);                                     // SPV-053
  464. ==
  465. ==
  466. == /* File: modem.c */
  467. ─────────────────────────────────────────────────────────────────────────────
  468. STEP 4: Recompile:  Redo the whole damn BBS!
  469. ─────────────────────────────────────────────────────────────────────────────
  470.   Thats it!  Just make sure that PBFILES.EXE is in your main BBS directory,
  471. (along with an appropriate inclusion file, if any) and you're off!
  472.  
  473.    This mod is copyright 1994-1996 by Tracy Baker, aka Papa Bear, and is
  474. distributed as freeware.  Permission is granted to distribute and post this
  475. mod on BBS systems and online services, provided no alterations are made
  476. (removal of message headers/taglines allowed).  This mod may contain some
  477. parts of WWIV source code, which is copyright 1988-1994 by Wayne Bell and
  478. licensed only to registered users of WWIV.  Use of WWIV source without
  479. registration constitutes a license violation and could lead to legal
  480. prosecution and certain doom.
  481.   Shareware distributors and CD-ROM publishers may not distribute this mod
  482. without express written permission of the Author or WWIV Software Services.
  483.