home *** CD-ROM | disk | FTP | other *** search
- // REGUSER.SCR Christmas Day 1992
- //
- // Utility to allow On-Line registration of callers by John Daniels
- // 3:690/688@FidoNet
- // Uses LASTUSER.BBS or LASTUS??.BBS (on multi nodes systems)
- //
- // Command line paramaters are:
- // 1) Task Number (returned by Maximus
- // %K)
- // 2) Number of days/months membership
- // any number less than 6 will register a
- // caller for 7 days!
- //
- // Needs to be called via Mecca Xtern_Erlvl command
- // eg [Xtern_Erlvl]156 %K 6
- // will exit with errorlevel 156
- // task No. and 6 months' membership
- //
- // Upon re-start (Max -r) Maximus reads LASTUS??.BBS and updates its in
- // memory data the current caller.
- //
- char *ufile = "LASTUSER.BBS";
- char *task = "00";
- char date[8], *p, *q, buff[8], *expdate, *yr, *mt, *dy, *buf;
-
- int newdate, advance, thedate, xtend, retval;
- int day, mont, year, ed, mn, ok, month;
- int ml[12];
- int j[12];
-
- long jn, nd, yy, jul;
- long a, b;
-
- main (int argc, char *arg1, char *arg2) // Main program
- {
- j[1]=0; j[2]=31; j[3]=28; j[4]=31; j[5]=30; j[6]=31;
- j[7]=30; j[8]=31; j[9]=31; j[10]=30; j[11]=31; j[12]=30;
-
- ml[1]=31; ml[2]=28; ml[3]=31; ml[4]=30; ml[5]=31; ml[6]=30;
- ml[7]=31; ml[8]=31; ml[9]=30; ml[10]=31; ml[11]=30; ml[12]=31;
-
-
- if (argc) strcpy(task,arg1);
- printf ("\n\nTask Number %s\n",task);
- strcpy(ufile,"LASTUS");
- strcat(ufile,task);
- strcat(ufile,".BBS");
- retval = strcmp(ufile,"LASTUS00.BBS");
- if (retval==0) {
- strcpy(ufile,"LASTUSER.BBS");
- }
- printf("Reading: %s\n",ufile);
- expdate = "";
- if (argc) xtend=atoi(arg2);
- if (xtend < 2) {
- retval = discdate();
- jul = julian(day,month,year);
- retval = revjul(jul+7);
- itoa(day,buf,10);
- if (day < 10) {
- expdate = strcat(expdate,"0");
- expdate = strcat(expdate,buf);
- }
- else
- {
- expdate = strcat(expdate,buf);
- }
- expdate = strcat(expdate,"-");
- itoa(mont,buf,10);
- if (mont < 10) {
- expdate = strcat(expdate,"0");
- expdate = strcat(expdate,buf);
- }
- else
- {
- expdate = strcat(expdate,buf);
- }
- expdate = strcat(expdate,"-");
- itoa(year-1900,buf,10);
- expdate = strcat(expdate,buf);
- printf("\nSeven Days FREE Membership...\n");
- }
- else
- {
- thedate = SysDate();
- newdate = GenDate(thedate,xtend);
- expdate = DateToStr(newdate);
- printf("\nSix Months Membership...\n");
- }
- printf ("New Expiry Date is %s\n\n",expdate);
- newdate = StrToDate(expdate);
-
- if (!BaseOpen (ufile)) {
- printf ("ERROR opening user file %s\n",ufile);
- exit ();
- }
-
- if (BaseRead (1)) {
- USRxpdate = newdate;
- USRpriv = PRIVIL;
- USRxpflag = XP_DATE_DEMOTE;
- USRxppriv = DISGRACE;
- BaseWrite (1);
- BaseClose ();
- exit();
- }
- }
-
- discdate ()
- {
- newdate=SysDate();
- buff=DateToStr(newdate);
- strcpy(date,buff); strcpy(p,date);
- day=atoi(p);
- strcpy(date,buff); strcpy(p,date);
- p++;p++;p++;
- month=atoi(p);
- strcpy(date,buff); strcpy(p,date);
- p++;p++;p++;p++;p++;p++;
- year=atoi(p)+1900;
- return 1;
- }
-
- revjul (long jj)
- {
- ok = 0;
- nd = (jj*100); year = (nd/36525);
- yy = (year * 36525); day = (nd - yy)/100;
- if (day == 0) {
- day = 31; mont = 12; year = year -1;
- return 1;
- }
- yy = (year * 100);
- if ( ((year*100) / 4) > ((year /4) * 100) ) {
- ml[2] = 28;
- }
- else {
- ml[2] = 29;
- }
- for (mn=1; day > (ml[mn])+1; mn++) {
- day = day - ml[mn];
- }
- mont = mn;
- return 1;
- }
-
- julian (int d, int m, int y)
- {
- yy = (y*100); nd = (yy*365); yy = (y/4)*100; nd = nd+yy;
- nd = (nd/100);
- ed = ( ((y*100)/4) - ((y/4)*100));
- if (ed > 0) {
- ed = 1;
- j[3]=28;
- }
- else {
- ed = 0;
- j[3]=29;
- }
- jn = 0;
- for (mn=1; mn<m+1; mn++) {
- jn = jn + j[mn];
- }
- jn = jn + d + nd + ed;
- return jn;
- }
-