home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / SYSOP / MODS1.ZIP / FPOINTS2.MOD < prev    next >
Text File  |  1990-06-27  |  16KB  |  588 lines

  1. /*****************************************************************************
  2.  
  3.                              File Points v2.0
  4.                                     by        
  5.                     The Wraith
  6.  
  7.       FOR: 4.10, 4.11, probably 4.12, ???
  8.  
  9.  
  10.       I have been hording this one for quite a while now..  pretty much
  11.   because i didn't want to have to write up this DOC.   But... since it is the
  12.   HUGEST thing I have ever done, i supposed i might as well.  I have heard some
  13.   rumors of File Points for WWIV being made in the past.. (most of them bad!)
  14.   but i am pretty sure that this has no bugs in it.  I have been running it for
  15.   about a half a year now.
  16.  
  17.       What this does is instead of relying completely on the QUANTITY of
  18.   files, this will allow your dloading to be based on the QUALITY of the file.
  19.   As i said this is not COMPLETELY on the normal Ratio, but it is partially,
  20.   since it's a LOT easier NOT to remove the ratio info..  So if you would
  21.   rather not have a ratio involved at ALL, then just set it to 0.000.  Mine is
  22.   set to .150 (just as a safeguard so that even if the files are GREAT, someone
  23.   wont be able to leech forever! heh.)  This may not be for you.   Since it
  24.   will mean that someone (probably you) will have to review every file, and
  25.   assign appropriate value to it..  but it has worked perfectly for me, and
  26.   two other boards in my area.....
  27.  
  28.       The basic idea is that when you upload a file, you get a certain number
  29.   of points for it..  and you can 'spend' the points on files that have a
  30.   certain point value placed on them.  Much like getting gold for posts, and 
  31.   spending it on games.
  32.  
  33.       Also..  This mod WILL snag THISUSER.GOLD.  I took the SALT mod out a
  34.   long time ago..  just coming to the conclusion that, "If i have a user that
  35.   would leech that massively on the games, i dont need him on my board.".. so
  36.   I used the GOLD.
  37.  
  38.       Now..  In version 1.0 (that was never released past my county.. heh) 
  39.   back when 4.07 was the latest.. i used the uploads varable 'mask' to store,
  40.   the points for each file that was uploaded, this was  forshadowing of 
  41.   Wayne's extended descriptions..  so, unfortunately.. to do this mod.  You
  42.   will have to delete ALL your files from the uploads  (not the REAL file, but
  43.   remove it from the dload section and say "No, do NOT delete the file" when
  44.   prompted.... I realize this will be almost TOTALLY impossible for large
  45.   boards, like a WWIV Support board or something..  but it's not going to be
  46.   THAT much of a chore for a smaller board (my board had 400 files at the time
  47.   I switched to points, and it took 2 hours to put em all back up It'll give
  48.   you a chance to see what you have in your dirs that you forgot about..
  49.      
  50.       Or you could write a small program that will convert the data, to a new
  51.   format (i.e. like Shai Hulud's CONVERT for the userlist.).  Too bad Wayne
  52.   failed to place 'reserved' bytes in the uploadsrec..  would have made things
  53.   so much simpler..
  54.  
  55.       There is one way to get around file points...  and that is through the
  56.   use of the Extract, and Archive TEMP.ZIP.  Now.. almost NO user out there is
  57.   smart enough to figure out how this sucker works to begin with.. and i have
  58.   not had a problem with it... but if i ever do.. that user/visting sysop will
  59.   be deleted (providing deceit was intentional..).  and that is all that
  60.   I could tell you out there to do.  You may also want to restrict access to
  61.   the temporary archiver to Co-Sysops or higher.
  62.  
  63.       I just timed myself..  and without rushing.. it took only 15 minutes
  64.   to install this mod in an unmoddified board.
  65.  
  66.  
  67. ******************************************************************************/
  68.  
  69.     The Real first thing to do..  
  70.  
  71.        Add this in your Vardec.h file..
  72.  
  73.  
  74. /* DATA HELD FOR EVERY UPLOAD */
  75. typedef struct {
  76.     char        filename[13],        /* filename */
  77.             description[59],    /* file description */
  78.             date[9],        /* date u/l'ed */
  79.             upby[46];        /* name of upload user */
  80.     unsigned char    filetype;        /* file type for apples */
  81.     unsigned short    numdloads,        /* number times d/l'ed */
  82.             ownersys,ownerusr,    /* who uploaded it */
  83. ++                      points,                 /* file points */
  84.             mask;            /* file type mask */
  85.     unsigned long    daten,            /* date uploaded */
  86.             numbytes;        /* number bytes long file is */
  87. } uploadsrec;
  88.  
  89.  
  90.         WARNING! THE ABOVE MODIFICATION WILL MAKE YOUR CURRENT TRANSFER SECTION
  91.   DATA FILES USELESS..  YOU WILL HAVE TO RE-ENTER ALL FILES IN ORDER YOU USE
  92.   THEM.
  93.  
  94.  
  95. FIRST
  96. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  97.  
  98. ONLY MOD TO BBS.C
  99.              ~~~~~
  100.  
  101.         if ((strcmp(s,"UPLOAD")==0) && (dcs()))
  102.           uploadall(udir[curdir].subnum);
  103.         if ((strcmp(s,"REN")==0) && (dcs())) {
  104.           helpl=39;
  105.           rename_file();
  106.          }
  107. ++      if ((strcmp(s,"/P")==0) && (so()))
  108. ++          file_points(1);
  109. ++      if ((strcmp(s,"POINTS")==0) && (so()))
  110. ++          file_points(0);
  111.         if ((strcmp(s,"MOVE")==0) && (dcs()))
  112.            move_file();
  113.         if ((strcmp(s,"SORT")==0) && (dcs())) {
  114.           nl();
  115.           prt(2,"Sort all dirs? ");
  116.  
  117.  
  118. SECOND
  119. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  120.  
  121.  ALL OTHER PORTIONS ARE FOUND IN XFER.C
  122.                                  ~~~~~~
  123.  
  124.     ( ADD THIS VOID TO THE END OF XFER.C )
  125.  
  126.  
  127. void file_points(int x)
  128. {
  129.   char s[81],s1[81],s2[81];
  130.   int i,abort=0;
  131.   uploadsrec u;
  132.   userrec uu;
  133.  
  134.   nl();
  135.   nl();
  136.   prt(2,"File to edit: ");
  137.   mpl(12);
  138.   input(s,12);
  139.   if (s[0]==0)
  140.     return;
  141.   if (strchr(s,'.')==NULL)
  142.     strcat(s,".*");
  143.   align(s);
  144.   dliscan();
  145.   nl();
  146.   i=recno(s);
  147.   while ((!hangup) && (i>0) && (!abort)) {
  148.     SETREC(i);
  149.     read(dlf,(void *)&u,sizeof(uploadsrec));
  150.     printfileinfo(&u,udir[curdir].subnum);
  151.     nl();
  152.     prt(2,"New Points(Q=Quit): ");
  153.     input(s1,3);
  154.      if (s1[0]) {
  155.      if (strcmp(s1,"Q")==0)
  156.     abort=1;
  157.      u.points=atoi(s1);
  158.  
  159.    SETREC(i);
  160.    write(dlf,(void *)&u,sizeof(uploadsrec));
  161.   if (x) {
  162.    read_user(u.ownerusr,&uu);
  163.         uu.gold+=u.points;
  164.         write_user(u.ownerusr,&uu);
  165.         close_user();
  166.      }
  167.      }
  168.   if(!abort)
  169.     i=nrecno(s,i);
  170.  }
  171.   closedl();
  172. }
  173.  
  174.  
  175. THIRD
  176. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  177.  
  178.    (REPLACE THIS *ENTIRE* VOID)
  179.  
  180.  
  181. void printinfo(uploadsrec *u, int *abort)
  182. {
  183.   char s[85],s1[40],s2[81],s3[80];
  184.   int i,next,fc;
  185.  
  186.   fc=thisuser.sysstatus & sysstatus_funky_colors;
  187.  
  188. if (fc) {
  189.   ansic(1);
  190.   strncpy(s,u->filename,8);
  191.   s[8]=0;
  192.   osan(s,abort,&next);
  193.   strncpy(s,&((u->filename)[8]),4);
  194.   s[4]=0;
  195.     ansic(2);
  196.   osan(s,abort,&next);
  197.     ansic(0);
  198.   osan(": ",abort,&next);
  199.  
  200.   if (u->points!=-1) {
  201.      ltoa((((u->numbytes)+1023)/1024),s1,10);
  202.      strcat(s1,"k");
  203.  
  204.   #ifdef CHECK_FOR_EXISTANCE
  205.      strcpy(s2,directories[udir[curdir].subnum].path);
  206.      strcat(s2,u->filename);
  207.      if (!exist(s2))
  208.        strcpy(s1,"BEG ");
  209.      #endif
  210.  
  211.    for (i=0; i<5-strlen(s1); i++)
  212.      s[i]=32;
  213.    s[i]=0;
  214.    strcat(s,s1);
  215.      ansic(3);
  216.    osan(s,abort,&next);
  217.  
  218.    itoa((u->points),s1,10);
  219.    for (i=0; i<3-strlen(s1); i++)
  220.      s[i]=32;
  221.    s[i]=0;
  222.    strcat(s,s1);
  223.    strcat(s,"pts");
  224.    ansic(7);
  225.    osan(s,abort,&next);
  226. } else {
  227.    strcpy(s,"UNVALIDATED");
  228.    ansic(6);
  229.    osan(s,abort,&next);
  230.  }
  231.      ansic(0);
  232.    osan(" :",abort,&next);
  233.      ansic(5);
  234.    pla(u->description,abort);
  235.    if ((!*abort) && (thisuser.num_extended) && (u->mask & mask_extended))
  236.      print_extended(u->filename,abort,thisuser.num_extended,1);
  237.    if (!(*abort))
  238.      ++num_listed;
  239.  
  240. } else {
  241.  
  242.   strcpy(s,u->filename);
  243.   strcat(s,": ");
  244.   if(u->mask!=1) {
  245.     ltoa((((u->numbytes)+1023)/1024),s1,10);
  246.     strcat(s1,"k");
  247.  
  248.     strcpy(s2,directories[udir[curdir].subnum].path);
  249.     strcat(s2,u->filename);
  250.     if (!exist(s2))
  251.     strcpy(s1,"BEG ");
  252.  
  253.     for (i=0; i<5-strlen(s1); i++)
  254.       strcat(s," ");
  255.     strcat(s,s1);
  256.     itoa((u->points),s1,10);
  257.     for (i=0; i<3-strlen(s1); i++)
  258.     strcat(s," ");
  259.     strcat(s,s1);
  260.     strcat(s,"pts");
  261.   } else
  262.     strcat(s,"UNVALIDATED");
  263.   strcat(s," :");
  264.   strcat(s,u->description);
  265.   pla(s,abort);
  266.    if ((!*abort) && (thisuser.num_extended) && (u->mask & mask_extended))
  267.      print_extended(u->filename,abort,thisuser.num_extended,1);
  268.   if (!(*abort))
  269.     ++num_listed;
  270.  }
  271. }
  272.  
  273. FOUTH
  274. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  275.  
  276.  
  277.  
  278. void upload(int dn)
  279. {
  280.   directoryrec d;
  281.   uploadsrec u,u1;
  282. .
  283. .
  284. .
  285.   u.ownerusr=usernum;
  286.   u.ownersys=0;
  287.   u.numdloads=0;
  288.   u.filetype=0;
  289.   u.mask=0;
  290. ++  u.points=-1;
  291.   strcpy(u.upby,nam1(&thisuser,usernum,syscfg.systemnumber));
  292.   strcpy(u.date,date());
  293.   nl();
  294.   ok=1;
  295.   xfer=1;
  296. .
  297. .
  298. .
  299.       pl("Please enter a one line description.");
  300.       outstr(": ");
  301. @@    inputl(u.description,49);
  302.       nl();
  303.       ss=NULL;
  304.       modify_extended_description(&ss);
  305. .
  306. .
  307. .
  308.         if (ok) {
  309.           l=filelength(f);
  310.           u.numbytes=l;
  311.           close(f);
  312.           ++thisuser.uploaded;
  313.           thisuser.uk += ((l+1023)/1024);
  314. ++      ++thisuser.gold;
  315.           time(&l);
  316.           u.daten=l;
  317.           for (i=numf; i>=1; i--) {
  318.             SETREC(i);
  319. .
  320. .
  321. .
  322.           print("Your ratio is now: ",s,"");
  323.           nl();
  324. ++      prt(7,"Here's a File Point for you until this file is validated.");
  325.       nl();
  326.           nl();
  327. .
  328. .
  329. .
  330.  
  331.   }
  332.   closedl();
  333. }
  334.  
  335. FIVE
  336. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  337.  
  338.  
  339.  
  340. /****************************************************************************/
  341. int try_to_download(char *s, int dn,int title)
  342. {
  343.   int i,ok,sent,abort,sp;
  344.   uploadsrec u;
  345.   char s1[81];
  346. .
  347. .
  348. .
  349. .
  350.     if ((printfileinfo(&u,dn)) || (strncmp(u.filename,"WWIV4",5)==0)) {
  351. ++      if (u.points!=-1) {
  352. ++      if((u.points>thisuser.gold) && (thisuser.exempt!=1)) {
  353. ++       nl();
  354. ++       prt(5,"You don't have enough File Points for this file.");
  355. ++       return(-1);
  356. ++      }
  357. ++    } else{
  358. ++    prt(3,"This file has not yet been validated.");
  359. ++    return(-1);
  360. ++    }
  361. .
  362. .
  363. .
  364.       send_file(s1,&sent,&abort,u.filetype,u.filename,dn, u.numbytes);
  365.       if (sent) {
  366.         ++thisuser.downloaded;
  367.         thisuser.dk += (int) ((u.numbytes+1023)/1024);
  368. ++    thisuser.gold-=u.points;
  369.         ++u.numdloads;
  370.         SETREC(i);
  371. .
  372. .
  373. .
  374.   else
  375.     return(1);
  376. }
  377. /****************************************************************************/
  378.  
  379.  
  380. void removefile()
  381. {
  382.   int i,i1,ok,rm,abort,rdlp;
  383.   char ch,s[81],s1[81];
  384.   uploadsrec u;
  385.   userrec uu;
  386. .
  387. .
  388. .
  389.             read_user(u.ownerusr,&uu);
  390.             --uu.uploaded;
  391.             uu.uk -= ((u.numbytes+1023)/1024);
  392. ++          uu.gold -= u.points;
  393.             write_user(u.ownerusr,&uu);
  394.             close_user();
  395. .
  396. .
  397. .
  398.   closedl();
  399. }
  400.  
  401. SIX
  402. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403.  
  404.  
  405.  
  406. int upload_file(char *fn, int dn)
  407. {
  408.   directoryrec d;
  409.   uploadsrec u,u1;
  410.   int i,i1,i2,ok,f;
  411.   char s[81],s1[81],ff[81];
  412.   long l;
  413.   double ti;
  414. .
  415. .
  416. .
  417.     u.ownerusr=usernum;
  418.     u.ownersys=0;
  419.     u.numdloads=0;
  420.     u.filetype=0;
  421.     u.mask=0;
  422. ++  u.points=-1;
  423.   strcpy(ff,d.path);
  424.   strcat(ff,s);
  425.   f=open(ff,O_RDONLY | O_BINARY);
  426.   l=filelength(f);
  427.   u.numbytes=l;
  428.   close(f);
  429.   strcpy(u.upby,nam1(&thisuser,usernum,syscfg.systemnumber));
  430.   strcpy(u.date,date());
  431.   if (d.mask & mask_PD)
  432.     d.mask=mask_PD;
  433.   strcpy(s,u.filename);
  434.   strcat(s,": ");
  435.   ltoa((((u.numbytes)+1023)/1024),s1,10);
  436.   strcat(s1,"k");
  437.   for (i=0; i<5-strlen(s1); i++)
  438.     strcat(s," ");
  439.   strcat(s,s1);
  440.   strcat(s," :");
  441.   outstr(s);
  442. @@  inputl(u.description,49);
  443.   if (u.description[0]==0)
  444.     return(0);
  445. ++  prt(5,"Enter Point Value: ");
  446. ++  inputl(s,3);
  447. ++  u.points=atoi(s);
  448. ++  thisuser.gold+=atoi(s);
  449. .
  450. .
  451. .
  452.   return(1);
  453. }
  454.  
  455. SEVEN
  456. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  457.  
  458.  
  459. void yourinfodl()
  460. {
  461.   char s[81],s1[81],s2[81],s3[81];
  462.  
  463.   itoa(thisuser.uploaded,s,10);
  464.   itoa(thisuser.downloaded,s1,10);
  465.   ltoa(thisuser.uk,s2,10);
  466.   ltoa(thisuser.dk,s3,10);
  467. .
  468. .
  469. .
  470.   print("Your DSL   : ",s,"");
  471. ++  itoa((int)thisuser.gold,s,10);
  472. ++  ansic(1);
  473. ++  print("File Points: ",s,"");
  474. ++  nl();
  475.  
  476. }
  477.  
  478. EIGHT
  479. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  480.  
  481.  
  482.     (IF YOU ARE USING BILBO BAGGINS Batch Dl Mod, YOU WILL HAVE TO FISH
  483.             OUT WHAT YOU CAN FROM THIS VOID.)
  484.  
  485. void batchdl()
  486. {
  487.   int i,abort,done,i1,i2,ok,had,rr;
  488.   char s[81],ch;
  489.   double percent;
  490.   uploadsrec u;
  491. .
  492. .
  493. .
  494.               sprintf(s,"%d files left, Time left = %s\r\n",numbatch,ctim(batchtime));
  495.               outs(s);
  496.               SETREC(i);
  497.               read(dlf,(void *)&u,sizeof(uploadsrec));
  498.               strcpy(s,directories[batchdir[0]].path);
  499.               strcat(s,u.filename);
  500. ++          if(thisuser.gold<u.points) {
  501. ++          prt(5,"Your File Points are too low to continue.");
  502.            endbatch();
  503.           }
  504.               xymodem_send(s,&ok,&percent,u.filetype,1,1,1);
  505.               if (ok) {
  506.                 ++thisuser.downloaded;
  507.                 thisuser.dk += (int) ((u.numbytes+1023)/1024);
  508.                 ++u.numdloads;
  509. ++         thisuser.gold-=u.points;
  510.                 SETREC(i);
  511.                 write(dlf,(void *)&u,sizeof(uploadsrec));
  512.                 strcpy(s,"Downloaded '");
  513.                 strcat(s,u.filename);
  514.                 strcat(s,"'");
  515.                 sysoplog2(5,s,0);
  516. .
  517. .
  518. .
  519.     }
  520.   } while ((!done) && (!hangup));
  521. }
  522.  
  523. /****************************************************************************/
  524.  
  525.      How to award points to a user
  526.      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  527.  
  528.          There are two ways to validate a file.
  529.  
  530.            //POINTS or /P in the Transfer section.  
  531.            ~~~~~~~~    ~~
  532.        //POINTS:  This function will allow you to change the number of points
  533.        ~~~~~~~~   placed on a given file.. this is used primarily to MODIFY
  534.                   existing points on a file.  As it DOES NOT award points to 
  535.                   the user that uploaded it.
  536.  
  537.              /P:  This function is what you should use on a file upon seeing it
  538.              ~~   in your Newscan, or marked as 'UNVALIDATED' this will allow
  539.                   you to assign points to a file, and at the same time, award
  540.                   this number of points to that user's account.  
  541.  
  542.  
  543.      Upon upload, a file is assigned the value of -1, which the BBS will recog-
  544.   nize, as UNVALIDATED, and no one will be able to download this file, until
  545.   you assign a point value to it.. (which can be -999 to 999 if you wish). The
  546.   user is given ONE file point upon upload.  This will eventually work in his
  547.   favor, but you aren't a tyrant are you?
  548.  
  549.  
  550.       <DISCLAIMER>
  551.  
  552.          I KNOW I'm not repsonsible for anything that happens to your computer,
  553.       or your wife, or your mother.  So.. There's really no need for me to go
  554.       into a lengthy explaination...  
  555.  
  556.   <Credits>
  557.  
  558.       Thanks goes to Peter Norton for writing this awesome Editor.
  559.       Thanks of COURSE to Wayne Bell.
  560.  
  561.     Donations are appreciated..  Make checks payable to 1@13123Lnk  heh
  562.  
  563. South of Heaven BBS
  564. 301-939-5195
  565.                 
  566. -------------------------------------------------------------------------------
  567.  
  568.                            File Points v2.0
  569.  
  570.                              Additions..
  571.  
  572. /*****************************************************************************
  573.      Crap.. i cant belive i forgot this part..    add this case to 
  574.  
  575.    void uedit, in file SYSOPF.C
  576. *****************************************************************************/
  577.  
  578.  
  579.        case 'F':
  580.        prt(2,"New File Points: ");
  581.        input(s,4);
  582.        i=atoi(s);
  583.        u.gold=i;
  584.        write_user(un,&u);
  585.        break;
  586.  
  587. <EOF>
  588.