home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / WWIV2.ZIP / LILO.C < prev    next >
Text File  |  1995-12-13  |  18KB  |  619 lines

  1. #include "vars.h"
  2.  
  3. #pragma hdrstop
  4.  
  5.  
  6.  
  7. void getuser(void)
  8. {
  9.   char s[81],s2[81],s3[81],s4[50],*ss;
  10.   int ok,count,net_only,ans,i;
  11.   long l;
  12.   FILE *f;
  13.  
  14.   thisuser.sysstatus &= (~sysstatus_ansi);
  15.   net_only=1;
  16.   if (syscfg.netlowtime!= syscfg.nethightime) {
  17.     if (syscfg.nethightime>syscfg.netlowtime) {
  18.       if ((timer()<=(syscfg.netlowtime*60.0)) || (timer()>=(syscfg.nethightime*60.0)))
  19.         net_only=0;
  20.     } else {
  21.       if ((timer()<=(syscfg.netlowtime*60.0)) && (timer()>=(syscfg.nethightime*60.0)))
  22.         net_only=0;
  23.     }
  24.   } else
  25.     net_only=0;
  26.   count=0;
  27.   ok=0;
  28.   checkit=1;
  29.   okmacro=0;
  30.   actsl=syscfg.newusersl;
  31.   if ((!net_only) && (incom)) {
  32.     sprintf(s,"%sWELCOME.ANS",languagedir);
  33.     if (exist(s)) {
  34.       nl();
  35. #ifdef OLD
  36.       outstr("Can you support ANSI graphics? ");
  37.       thisuser.sysstatus=0;
  38.       ans=yn();
  39. #else
  40.       ans=check_ansi();
  41. #endif
  42.       if (ans>0) {
  43.     printfile("welcome.ans");
  44.     printfile("games.msg");
  45.       } else if (ans==0) {
  46.     printfile("welcome.msg");
  47.       printfile("games.msg");}
  48.     } else {
  49.       printfile("welcome.msg");
  50.       printfile("games.msg"); }
  51.   }
  52.   if (curatr!=7)
  53.     reset_colors();
  54.   do {
  55.     nl();
  56.     if (net_only) {
  57.       pl(get_string(353));
  58.       pl(get_string(354));
  59.     } else
  60.       pl("If you call waiting is not disabled or someone might pick up");
  61.       pl("the phone during your call, hit [Enter] three times so the");
  62.       pl("BBS will disconnect you, and call back when you are sure that");
  63.       pl("nothing will abruptly interrupt your call.");
  64.       pl(get_string(355));
  65.     outstr(get_string(356)); /* DON'T change the NN: prompt. */
  66.     input(s,30);
  67.     usernum=finduser(s);
  68.     if ((net_only) && (usernum!=-2))
  69.       usernum=0;
  70.     if (usernum>0) {
  71.       read_user(usernum,&thisuser);
  72.       read_qscn(usernum,qsc,0);
  73.       actsl = syscfg.newusersl;
  74.       topscreen();
  75.       ok=1;
  76.       outstr("1Password7 : ");
  77.       echo=0;
  78.       input(s,8);
  79.       if (strcmp(s,thisuser.pw)!=0)
  80.         ok=0;
  81.       if ((syscfg.sysconfig & sysconfig_free_phone)==0) {
  82.     outstr("1Phone ■■■7-1■■■7-1");
  83.         echo=0;
  84.         input(s2,4);
  85.         if (strcmp(s2,&thisuser.phone[8])!=0) {
  86.           ok=0;
  87.           if ((strlen(s2)==4) && (s2[3]=='-')) {
  88.             nl();
  89.         pl("6!! 5Enter the last 4 digits of your phone number only 6!!");
  90.             nl();
  91.           }
  92.         }
  93.       }
  94.       if ((thisuser.sl==255) && (incom) && (ok)) {
  95.     outstr("1System PW 7: ");
  96.         echo=0;
  97.         input(s,20);
  98.         if (strcmp(s,syscfg.systempw)!=0)
  99.           ok=0;
  100.       }
  101.       echo=1;
  102.       if (ok) {
  103.         reset_act_sl();
  104.         changedsl();
  105.       } else {
  106.         ++thisuser.illegal;
  107.         write_user(usernum,&thisuser);
  108.         close_user();
  109.         nl();
  110.     pl("6ILLEGAL LOGON!");
  111.         nl();
  112.         sprintf(s3,get_stringx(1,21),
  113.                 nam(&thisuser,usernum),
  114.                 ctim(timer()),
  115.                 s);
  116.         if ((syscfg.sysconfig & sysconfig_free_phone)==0) {
  117.           sprintf(s4,get_stringx(1,22),s2);
  118.           strcat(s3,s4);
  119.         }
  120.         sl1(0,"");
  121.         sl1(0,s3);
  122.         sl1(0,"");
  123.     usernum=0;
  124.       }
  125.     } else
  126.       if (usernum==-1) {
  127.         newuser();
  128.         ok=1;
  129.       } else
  130.         if (usernum==0) {
  131.       if (net_only)
  132.         nl();
  133.       else
  134.         pl("6Unknown User");
  135.         } else
  136.           if ((usernum==-2) || (usernum==-3) || (usernum==-4)) {
  137.             if (incom) {
  138.               save_status();
  139.               time(&l);
  140.               s2[0]=0;
  141.               switch(usernum) {
  142.                 case -2:
  143.                   sprintf(s2,"NETWORK /B%u /T%ld /F%u",modem_speed,l,modem_flag);
  144.                   run_external1(s2);
  145.                   break;
  146.                 case -3:
  147.                   sprintf(s2,"REMOTE /B%u /F%u",modem_speed,modem_flag);
  148.                   run_external1(s2);
  149.                   break;
  150.                 case -4:
  151.                   s[8]=0;
  152.                   if (s[0]) {
  153.                     sprintf(s2,"%s /B%u /F%u",s,modem_speed,modem_flag);
  154.                     sprintf(s3,"%sREMOTES.DAT",syscfg.datadir);
  155.                     f=fopen(s3,"rt");
  156.                     if (f) {
  157.                       ok=0;
  158.                       while ((!ok) && (fgets(s3,80,f))) {
  159.                         ss=strchr(s3,'\n');
  160.                         if (ss)
  161.                           *ss=0;
  162.                         if (stricmp(s3,s)==0)
  163.                           ok=1;
  164.                       }
  165.                       fclose(f);
  166.                       if (ok) {
  167.                         shrink_out(s2, -1, 0, 0, 1);
  168.                         run_external1(s2);
  169.                       }
  170.                     }
  171.                   }
  172.                   break;
  173.               }
  174.               l=status.qscanptr;
  175.               get_status();
  176.               if (l!=status.qscanptr) {
  177.                 for (i=0; i<num_subs; i++) {
  178.                   sub_dates[i]=0L;
  179.                 }
  180.               }
  181.               hangup=1;
  182.               dtr(0);
  183.               global_xx=0;
  184.               wait(1.0);
  185.               dtr(1);
  186.               wait(0.1);
  187.           cleanup_net();
  188.               imodem(0);
  189.         }
  190.         hangup=1;
  191.           }
  192.  
  193.   } while ((!hangup) && (!ok) && (++count<3));
  194.   if (count==3)
  195.     hangup=1;
  196.   checkit=0;
  197.   okmacro=1;
  198.   if ((!hangup) && (usernum>0) && (thisuser.restrict & restrict_logon) &&
  199.     (strcmp(date(),thisuser.laston)==0) && (thisuser.ontoday>0)) {
  200.     nl();
  201.     pl("1Sorry, you can only logon once per day.");
  202.     nl();
  203.     hangup=1;
  204.   }
  205. }
  206.  
  207.  
  208. void logon(void)
  209. {
  210.   char s[255],s1[181],s2[81],*ss;
  211.   int i,i1,f;
  212.   long len,pos;
  213.  
  214.   if (usernum<1) {
  215.     hangup=1;
  216.     return;
  217.   }
  218.  
  219.   if (live_user) {
  220.     reset_colors();
  221.     ansic(0);
  222.     outchr(12);
  223.   }
  224.   if (incom && live_user) {
  225.     i=printfile("LOGON");
  226.     if ((!i) && (!(thisuser.sysstatus & sysstatus_pause_on_page)))
  227.       pausescr();
  228.   }
  229.  
  230.   strcpy(xdate,date());
  231.   if (strcmp(xdate,thisuser.laston)==0)
  232.     ++thisuser.ontoday;
  233.   else {
  234.     thisuser.ontoday=1;
  235.     thisuser.timeontoday=0.0;
  236.     thisuser.extratime=0.0;
  237.     thisuser.posttoday=0;
  238.     thisuser.etoday=0;
  239.     thisuser.fsenttoday1=0;
  240.   }
  241.   ++thisuser.logons;
  242.   cursub=0;
  243.   msgreadlogon=0;
  244.   if (udir[0].subnum==0)
  245.     curdir=1;
  246.   else
  247.     curdir=0;
  248.   curdloads=0;
  249.   if (actsl!=255) {
  250.     ++status.callernum1;
  251.     ++status.callstoday;
  252.   }
  253.   sprintf(s,"%ld: %s %s %s   %s - %d",
  254.        status.callernum1,
  255.        nam(&thisuser,usernum),
  256.        times(),
  257.        date(),
  258.        curspeed,
  259.        thisuser.ontoday);
  260.  
  261.   sprintf(s2,"%sLASTON.TXT",syscfg.gfilesdir);
  262.   ss=get_file(s2,&len);
  263.   pos=0;
  264.   if (ss!=NULL) {
  265.     if (!cs())
  266.       for (i=0; i<4; i++)
  267.     copy_line(s1,ss,&pos,len);
  268.     i=1;
  269.     do {
  270.       copy_line(s1,ss,&pos,len);
  271.       if ((s1[0]) && live_user) {
  272.     if (i) {
  273.       i=0;
  274.       nl();
  275.       nl();
  276.       pl("7╓══════════════════════════════════════════════════════════╖");
  277.       pl("7║                     2Last Few Callers7                     ║");
  278.       pl("7╠══════════════════════════════════════════════════════════╣");
  279.       pl("7║ Caller   User                             Speed-On Today ║");
  280.     }
  281.     pl(s1);
  282.       }
  283.     } while (pos<len);
  284.   }
  285.   if ((actsl!=255) || (incom)) {
  286.     sl1(0,"");
  287.     sl1(0,s);
  288.     sl1(1,"");
  289.     sprintf(s,"7║ 1%-5ld3: 1%-35s   %-6s 3- 1%-2d7 ║\r\n",
  290.           status.callernum1,
  291.           nam(&thisuser,usernum),
  292.           curspeed,
  293.           thisuser.ontoday);
  294.     sprintf(s1,"%sUSER.LOG",syscfg.gfilesdir);
  295.     f=open(s1,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  296.     lseek(f,0L,SEEK_END);
  297.     i=strlen(s);
  298.     if (actsl!=255) {
  299.       write(f,(void *)s,i);
  300.       close(f);
  301.       f=open(s2,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
  302.       pos=0;
  303.       copy_line(s1,ss,&pos,len);
  304.       for (i=1; i<8; i++) {
  305.         copy_line(s1,ss,&pos,len);
  306.         strcat(s1,"\r\n");
  307.         write(f,(void *)s1,strlen(s1));
  308.       }
  309.       write(f,(void *)s,strlen(s));
  310.       close(f);
  311.     } else
  312.       close(f);
  313.   }
  314.       pl("7╚══════════════════════════════════════════════════════════╝");
  315.  
  316.   if (ss!=NULL)
  317.     farfree(ss);
  318.  
  319.   if (live_user)
  320.     read_automessage();
  321.   timeon=timer();
  322.   useron=1;
  323.   if (live_user)
  324.     topscreen();
  325.  
  326.   if ((syscfg.logon_c[0]) && live_user) {
  327.     nl();
  328.     stuff_in(s,syscfg.logon_c,create_chain_file("CHAIN.TXT"),"","","","");
  329.     full_external(s,0,1);
  330.     nl();
  331.     nl();
  332.   }
  333.  
  334.   if (live_user) {
  335.     nl();
  336.     pl("5┌──────────────────────────────────────────────────────────────────────────┐");
  337.     pl("5│              2              Your Information                             5 │");
  338.     pl("5│                                                                          │");
  339.    npr("5│ 3Name   5: 3%-31s Real name5: 3%-21s5│\r\n",nam(&thisuser,usernum),thisuser.realname);
  340.    npr("5│ 3Address5: 3%-31s %-31s5 │\r\n",thisuser.street,thisuser.city);
  341.    npr("5│ 3Phone  5: 3%-13s %-13s5                                     │\r\n",thisuser.phone,thisuser.dataphone);
  342.    npr("5│                                                                          │\r\n");
  343.    npr("5│ 1Please let the sysop know if any of this information is incorrect7.5       │\r\n");
  344.     pl("5└──────────────────────────────────────────────────────────────────────────┘");
  345.     nl();
  346.     pausescr();
  347.     outchr(12);
  348.     nl();
  349.     pl("7┌──────────────────────────────────────────────────────────────────────────┐");
  350.     pl("7│                             1Your Stats              7                     │");
  351.     pl("7│                                                                          │");
  352.    npr("7│ 1SL         7:1%-3d           DSL           7:1%-32d7│\r\n",thisuser.sl,thisuser.dsl);
  353.    npr("7│ 1Laston     7:1%-9s     Times on      7:1%-6d        On today 7:1%-8d7│\r\n",thisuser.laston,thisuser.logons,thisuser.ontoday);
  354.    npr("7│ 1Time on    7:1%-10ld    Illegal logons7:1%-4d          Mail7     :1%-8d7│\r\n",(long)((thisuser.timeon+timer()-timeon)/60.0),thisuser.illegal,thisuser.waiting);
  355.    npr("7│ 1Msgs Posted7:1%-10d    E-mail sent   7:1%-10d    P/C Ratio7:1%-5.3f   7│\r\n",thisuser.msgpost,thisuser.emailsent,post_ratio());
  356.    npr("7│ 1ULk        7:1%-10ld    DLk           7:1%-10ld    U/D Ratio7:1%-6.3f  7│\r\n",thisuser.uk,thisuser.dk,ratio());
  357.    npr("7│ 1Ass points 7:1%-3d           Time allowed  7:1%-32d7│\r\n",thisuser.ass_pts,(int)((nsl()+30)/60.0));
  358.    npr("7│ 1Personal Tag  7:1%-58s7│\r\n",thisuser.ptag);
  359.     pl("7└──────────────────────────────────────────────────────────────────────────┘");
  360.     nl();
  361.     pausescr();
  362.     outchr(12);
  363.     pl("5┌─────────────────────────────────────────────┐");
  364.     pl("5│3            System Information       5        │");
  365.     pl("5│                                             │");
  366.    npr("5│2 Total number of users5:2%-22d5│\r\n",status.users);
  367.    npr("5│2 Total number of calls5:2%-22d5│\r\n",status.callernum1);
  368.    npr("5│2 Calls today          5:2%-22d5│\r\n",status.callstoday);
  369.    npr("5│2 Msgs posted today    5:2%-22d5│\r\n",status.msgposttoday);
  370.    npr("5│2 Uploads today        5:2%-22d5│\r\n",status.uptoday);
  371.    npr("5│2 WWIV Registration    5:2%-22ld5│\r\n",syscfg.wwiv_reg_number);
  372.    if (!sysop2())
  373.    npr("5│2 Sysop is             5:2Out LLama Tipping!    5│\r\n");
  374.    else
  375.    npr("5│2 Sysop is             5:2Available for chat!   5│\r\n");
  376.    npr("5│2 WWIV version is      5:2%-22s5│\r\n",wwiv_version);
  377.    npr("5│2 Network version is   5:2%-22u5│\r\n",status.net_version);
  378.    npr("5│2 Networks :                                  5│\r\n");
  379.     for (i=0; i<net_num_max; i++) {
  380.       if (net_networks[i].sysnum) {
  381.     sprintf(s,"5│ 2%-14s %s",net_networks[i].name, get_string(370));
  382.     for (i1=strlen(s); i1<15; i1++)
  383.       s[i1]=' ';
  384.     s[i1]=0;
  385.     sprintf(s1,"2%-5s  5: 2@%-20u5│",s,net_networks[i].sysnum);
  386.     if (i)
  387.       pl(s1);
  388.     else {
  389.       for (i1=strlen(s1); i1<23; i1++)
  390.         s1[i1]=' ';
  391.       s1[i1]=0;
  392.       npr("2%s\r\n",s1);
  393.     }
  394.       }
  395.     }
  396.     pl("5└─────────────────────────────────────────────┘");
  397.     nl();
  398.     if (thisuser.forwardusr) {
  399.       if (thisuser.forwardsys) {
  400.         set_net_num(thisuser.net_num);
  401.         if (!valid_system(thisuser.forwardsys)) {
  402.           thisuser.forwardusr=0;
  403.           thisuser.forwardsys=0;
  404.           strcpy(s1,get_string(371));
  405.         } else {
  406.           strcpy(s1,get_string(372));
  407.           if (net_num_max>1)
  408.             sprintf(s2,"%s #%u @%u.",
  409.                 net_name,thisuser.forwardusr,thisuser.forwardsys);
  410.           else
  411.             sprintf(s2,"#%u @%u.",
  412.                 thisuser.forwardusr,thisuser.forwardsys);
  413.           strcat(s1,s2);
  414.         }
  415.       } else {
  416.         if (thisuser.forwardusr==65535)
  417.           strcpy(s1,get_string(373));
  418.         else {
  419.           strcpy(s1,get_string(372));
  420.           sprintf(s2,"#%u.",thisuser.forwardusr);
  421.           strcat(s1,s2);
  422.         }
  423.       }
  424.       pl(s1);
  425.       nl();
  426.     }
  427.     if (ltime) {
  428.       nl();
  429.       pl(get_string(374));
  430.       nl();
  431.     }
  432.     fsenttoday=0;
  433.  
  434.     if (thisuser.year) {
  435.       s[0]=years_old(thisuser.month,thisuser.day,thisuser.year);
  436.       if (thisuser.age!=s[0]) {
  437.         thisuser.age=s[0];
  438.         topscreen();
  439.       }
  440.     } else {
  441.       nl();
  442.       pl(get_string(375));
  443.       do {
  444.         nl();
  445.         input_age(&thisuser);
  446.         sprintf(s,"%02d/%02d/%02d",(int) thisuser.month,
  447.                                 (int) thisuser.day,
  448.                                 (int) thisuser.year);
  449.         nl();
  450.         outstr(s);
  451.         outstr(get_string(376));
  452.         if (!yn())
  453.           thisuser.year=0;
  454.       } while ((!hangup) && (thisuser.year==0));
  455.     }
  456.     if (syscfg.sysconfig & sysconfig_extended_info) {
  457.       if (!thisuser.street[0])
  458.         input_street();
  459.       if (!thisuser.city[0])
  460.         input_city();
  461.       if (!thisuser.state[0])
  462.         input_state();
  463.       if (!thisuser.country[0])
  464.         input_country();
  465.       if (!thisuser.zipcode[0])
  466.         input_zipcode();
  467.       if (!thisuser.dataphone[0])
  468.         input_dataphone();
  469.     }
  470.     topscreen();
  471.     nl();
  472.  
  473.     rsm(usernum,&thisuser);
  474.     if (thisuser.waiting) {
  475.       prt(5,get_string(377));
  476.       if (yn())
  477.         readmail();
  478.     }
  479.   }
  480.   nscandate=thisuser.daten;
  481.   batchtime=0.0;
  482.   numbatchdl=numbatch=0;
  483.   i1=0;
  484.   for (i=0; i<20; i++) {
  485.     if (questused[i])
  486.       if (thisuser.votes[i]==0)
  487.     i1=1;
  488.   }
  489.   if (restrict_vote & thisuser.restrict)
  490.     i1=0;
  491.   if (actsl<=10)
  492.     i1=0;
  493.   if (i1 && live_user) {
  494.     nl();
  495.     prt(3,get_string(378));
  496.     nl();
  497.     pausescr();
  498.     vote();
  499.     nl();
  500.     nl();
  501.   }
  502.   i=0;
  503.   express=0;
  504.   expressabort=0;
  505.   qscan(cursub,&i);
  506.   nl();
  507.   prt(5,"Scan for new messages? ");
  508.    if(ny()) {
  509.     express=0;
  510.     expressabort=0;
  511.     nscan(0);
  512.    }
  513.   save_status();
  514.   create_chain_file("CHAIN.TXT");
  515. }
  516.  
  517.  
  518. void logoff(void)
  519. {
  520.   long l;
  521.   int f,r,w,t,i;
  522.   char s[81];
  523.   mailrec m;
  524.   shortmsgrec sm;
  525.   double ton;
  526.  
  527.   dtr(0);
  528.   hangup=1;
  529.  
  530.   if (usernum<1)
  531.     return;
  532.  
  533.   thisuser.lastrate=modem_speed;
  534.   strcpy(thisuser.laston,xdate);
  535.   thisuser.illegal=0;
  536.   if ((timer()-timeon)<-30.0)
  537.     timeon-=24.0*3600.0;
  538.   ton=timer()-timeon;
  539.   thisuser.timeon += ton;
  540.   thisuser.timeontoday += (ton-extratimecall);
  541.   status.activetoday += (int) (ton/60.0);
  542.   save_status();
  543.  
  544.  
  545.   time(&l);
  546.   thisuser.daten=l;
  547.   close_user();
  548.   write_user(usernum,&thisuser);
  549.   write_qscn(usernum,qsc,0);
  550.   close_user();
  551.  
  552.   sprintf(s,get_stringx(1,23),msgreadlogon,
  553.         (int)((timer()-timeon)/60.0));
  554.  
  555.   if ((incom) || (actsl!=255))
  556.     sl1(0,s);
  557.  
  558.   if (mailcheck) {
  559.     sprintf(s,"%sEMAIL.DAT",syscfg.datadir);
  560.     f=open(s,O_BINARY | O_RDWR);
  561.     if (f!=-1) {
  562.       t=(int) (filelength(f)/sizeof(mailrec));
  563.       r=0;
  564.       w=0;
  565.       while (r<t) {
  566.         lseek(f,(long)(sizeof(mailrec)) * (long)(r),SEEK_SET);
  567.         read(f,(void *)&m,sizeof(mailrec));
  568.         if ((m.tosys!=0) || (m.touser!=0)) {
  569.           if (r!=w) {
  570.             lseek(f,(long)(sizeof(mailrec)) * (long)(w),SEEK_SET);
  571.             write(f,(void *)&m,sizeof(mailrec));
  572.           }
  573.           ++w;
  574.         }
  575.         ++r;
  576.       }
  577.       chsize(f,(long)(sizeof(mailrec)) * (long)(w));
  578.       close(f);
  579.     }
  580.   }
  581.  
  582.   if (smwcheck) {
  583.     sprintf(s,"%sSMW.DAT",syscfg.datadir);
  584.     f=open(s,O_BINARY | O_RDWR);
  585.     if (f!=-1) {
  586.       t=(int) (filelength(f)/sizeof(shortmsgrec));
  587.       r=0;
  588.       w=0;
  589.       while (r<t) {
  590.         lseek(f,(long)(sizeof(shortmsgrec)) * (long)(r),SEEK_SET);
  591.         read(f,(void *)&sm,sizeof(shortmsgrec));
  592.         if ((sm.tosys!=0) || (sm.touser!=0)) {
  593.           if (r!=w) {
  594.             lseek(f,(long)(sizeof(shortmsgrec)) * (long)(w),SEEK_SET);
  595.             write(f,(void *)&sm,sizeof(shortmsgrec));
  596.           }
  597.           ++w;
  598.         }
  599.         ++r;
  600.       }
  601.       chsize(f,(long)(sizeof(shortmsgrec)) * (long)(w));
  602.       close(f);
  603.     }
  604.   }
  605.   remove_from_temp("*.*", syscfg.tempdir, 0);
  606.   remove_from_temp("*.*", syscfg.batchdir, 0);
  607.  
  608.   if (numbatch && (numbatch != numbatchdl)) {
  609.     for (i=0; i<numbatch; i++) {
  610.       if (!batch[i].sending) {
  611.         didnt_upload(i);
  612.       }
  613.     }
  614.   }
  615.   numbatch=numbatchdl=0;
  616. }
  617.  
  618.  
  619.