コード例 #1
0
ファイル: newuser.cpp プロジェクト: insidenothing/wwiv
static int find_new_usernum(const WUser* pUser, uint32_t* qsc) {
  File userFile(syscfg.datadir, USER_LST);
  for (int i = 0; !userFile.IsOpen() && (i < 20); i++) {
    if (!userFile.Open(File::modeBinary | File::modeReadWrite | File::modeCreateFile)) {
      Wait(0.1);
    }
  }
  if (!userFile.IsOpen()) {
    return -1;
  }

  int nNewUserNumber = static_cast<int>((userFile.GetLength() / syscfg.userreclen) - 1);
  userFile.Seek(syscfg.userreclen, File::seekBegin);
  int nUserNumber = 1;

  if (nNewUserNumber == application()->GetStatusManager()->GetUserCount()) {
    nUserNumber = nNewUserNumber + 1;
  } else {
    while (nUserNumber <= nNewUserNumber) {
      if (nUserNumber % 25 == 0) {
        userFile.Close();
        for (int n = 0; !userFile.IsOpen() && (n < 20); n++) {
          if (!userFile.Open(File::modeBinary | File::modeReadWrite | File::modeCreateFile)) {
            Wait(0.1);
          }
        }
        if (!userFile.IsOpen()) {
          return -1;
        }
        userFile.Seek(static_cast<long>(nUserNumber * syscfg.userreclen), File::seekBegin);
        nNewUserNumber = static_cast<int>((userFile.GetLength() / syscfg.userreclen) - 1);
      }
      WUser tu;
      userFile.Read(&tu.data, syscfg.userreclen);

      if (tu.IsUserDeleted() && tu.GetSl() != 255) {
        userFile.Seek(static_cast<long>(nUserNumber * syscfg.userreclen), File::seekBegin);
        userFile.Write(&pUser->data, syscfg.userreclen);
        userFile.Close();
        write_qscn(nUserNumber, qsc, false);
        InsertSmallRecord(nUserNumber, pUser->GetName());
        return nUserNumber;
      } else {
        nUserNumber++;
      }
    }
  }

  if (nUserNumber <= syscfg.maxusers) {
    userFile.Seek(static_cast<long>(nUserNumber * syscfg.userreclen), File::seekBegin);
    userFile.Write(&pUser->data, syscfg.userreclen);
    userFile.Close();
    write_qscn(nUserNumber, qsc, false);
    InsertSmallRecord(nUserNumber, pUser->GetName());
    return nUserNumber;
  } else {
    userFile.Close();
    return -1;
  }
}
コード例 #2
0
ファイル: finduser.cpp プロジェクト: bhaggerty/wwiv
//
// Returns user number
//      or 0 if user not found
//      or special value
//
// This function will remove the special characters from arround the searchString that are
// used by the network and remote, etc.
//
// Special values:
//
//  -1      = NEW USER
//  -2      = WWIVnet
//  -3      = Remote Command
//  -4      = Unknown Special Login
//
int finduser(const std::string searchString) {
  WUser user;

  guest_user = false;
  GetApplication()->GetUserManager()->SetUserWritesAllowed(true);
  if (searchString == "NEW") {
    return -1;
  }
  if (searchString == "!-@NETWORK@-!") {
    return -2;
  }
  if (searchString == "!-@REMOTE@-!") {
    return -3;
  }
  int nUserNumber = atoi(searchString.c_str());
  if (nUserNumber > 0) {
    GetApplication()->GetUserManager()->ReadUser(&user, nUserNumber);
    if (user.IsUserDeleted()) {
      //printf( "DEBUG: User %s is deleted!\r\n", user.GetName() );
      return 0;
    }
    return nUserNumber;
  }
  nUserNumber = GetApplication()->GetUserManager()->FindUser(searchString);
  if (nUserNumber == 0L) {
    return 0;
  } else {
    GetApplication()->GetUserManager()->ReadUser(&user, nUserNumber);
    if (user.IsUserDeleted()) {
      return 0;
    } else {
      if (IsEqualsIgnoreCase(user.GetName(), "GUEST")) {
        guest_user = true;
        GetApplication()->GetUserManager()->SetUserWritesAllowed(false);
      }
      return nUserNumber;
    }
  }
}
コード例 #3
0
ファイル: sysopf.cpp プロジェクト: bhaggerty/wwiv
void reset_files() {
  WUser user;

  WStatus* pStatus = GetApplication()->GetStatusManager()->BeginTransaction();
  pStatus->SetNumUsers(0);
  GetSession()->bout.NewLine();
  int nNumUsers = GetApplication()->GetUserManager()->GetNumberOfUserRecords();
  WFile userFile(syscfg.datadir, USER_LST);
  if (userFile.Open(WFile::modeBinary | WFile::modeReadWrite)) {
    for (int i = 1; i <= nNumUsers; i++) {
      long pos = static_cast<long>(syscfg.userreclen) * static_cast<long>(i);
      userFile.Seek(pos, WFile::seekBegin);
      userFile.Read(&user.data, syscfg.userreclen);
      if (!user.IsUserDeleted()) {
        user.FixUp();
        if (isr1(i, nNumUsers, user.GetName())) {
          pStatus->IncrementNumUsers();
        }
      } else {
        memset(&user.data, 0, syscfg.userreclen);
        user.SetInactFlag(0);
        user.SetInactFlag(inact_deleted);
      }
      userFile.Seek(pos, WFile::seekBegin);
      userFile.Write(&user.data, syscfg.userreclen);
      if ((i % 10) == 0) {
        userFile.Close();
        GetSession()->bout << i << "\r ";
        userFile.Open(WFile::modeBinary | WFile::modeReadWrite);
      }
    }
    userFile.Close();
  }
  GetSession()->bout << "\r\n\r\n";

  WFile namesFile(syscfg.datadir, NAMES_LST);
  if (!namesFile.Open(WFile::modeReadWrite | WFile::modeBinary | WFile::modeTruncate)) {
    std::cout << namesFile.GetFullPathName() << " NOT FOUND" << std::endl;
    GetApplication()->AbortBBS(true);
  }
  namesFile.Write(smallist, sizeof(smalrec) * pStatus->GetNumUsers());
  namesFile.Close();
  GetApplication()->GetStatusManager()->CommitTransaction(pStatus);
}
コード例 #4
0
ファイル: batch.cpp プロジェクト: bhaggerty/wwiv
void downloaded(char *pszFileName, long lCharsPerSecond) {
  uploadsrec u;

  for (int i1 = 0; i1 < GetSession()->numbatch; i1++) {
    if (wwiv::strings::IsEquals(pszFileName, batch[i1].filename) &&
        batch[i1].sending) {
      dliscan1(batch[i1].dir);
      int nRecNum = recno(batch[i1].filename);
      if (nRecNum > 0) {
        WFile file(g_szDownloadFileName);
        file.Open(WFile::modeReadWrite | WFile::modeBinary | WFile::modeCreateFile,
                  WFile::shareUnknown, WFile::permReadWrite);
        FileAreaSetRecord(file, nRecNum);
        file.Read(&u, sizeof(uploadsrec));
        GetSession()->GetCurrentUser()->SetFilesDownloaded(GetSession()->GetCurrentUser()->GetFilesDownloaded() + 1);
        GetSession()->GetCurrentUser()->SetDownloadK(GetSession()->GetCurrentUser()->GetDownloadK() +
            static_cast<int>(bytes_to_k(u.numbytes)));
        ++u.numdloads;
        FileAreaSetRecord(file, nRecNum);
        file.Write(&u, sizeof(uploadsrec));
        file.Close();
        if (lCharsPerSecond) {
          sysoplogf("Downloaded \"%s\" (%ld cps)", u.filename, lCharsPerSecond);
        } else {
          sysoplogf("Downloaded \"%s\"", u.filename);
        }
        if (syscfg.sysconfig & sysconfig_log_dl) {
          WUser user;
          GetApplication()->GetUserManager()->ReadUser(&user, u.ownerusr);
          if (!user.IsUserDeleted()) {
            if (date_to_daten(user.GetFirstOn()) < static_cast<signed int>(u.daten)) {
              ssm(u.ownerusr, 0, "%s downloaded|#1 \"%s\" |#7on %s",
                  GetSession()->GetCurrentUser()->GetUserNameAndNumber(GetSession()->usernum), u.filename, fulldate());
            }
          }
        }
      }
      delbatch(i1);
      return;
    }
  }
  sysoplogf("!!! Couldn't find \"%s\" in DL batch queue.", pszFileName);
}
コード例 #5
0
ファイル: sysopf.cpp プロジェクト: bhaggerty/wwiv
void auto_purge() {
  char s[80];
  unsigned int days = 0;
  int skipsl = 0;

  IniFile iniFile(FilePath(GetApplication()->GetHomeDir(), WWIV_INI), INI_TAG);
  if (iniFile.IsOpen()) {
    days = iniFile.GetNumericValue("AUTO_USER_PURGE");
    skipsl = iniFile.GetNumericValue("NO_PURGE_SL");
  }
  iniFile.Close();

  if (days < 60) {
    if (days > 0) {
      sysoplog("!!! WARNING: Auto-Purge canceled [AUTO_USER_PURGE < 60]", false);
      sysoplog("!!! WARNING: Edit WWIV.INI and Fix this", false);
    }
    return;
  }

  time_t tTime = time(NULL);
  int nUserNumber = 1;
  sysoplogfi(false, "Auto-Purged Inactive Users (over %d days, SL less than %d)", days, skipsl);

  do {
    WUser user;
    GetApplication()->GetUserManager()->ReadUser(&user, nUserNumber);
    if (!user.IsExemptAutoDelete()) {
      unsigned int d = static_cast<unsigned int>((tTime - user.GetLastOnDateNumber()) / SECONDS_PER_DAY_FLOAT);
      // if user is not already deleted && SL<NO_PURGE_SL && last_logon
      // greater than AUTO_USER_PURGE days ago
      if (!user.IsUserDeleted() && user.GetSl() < skipsl && d > days) {
        sprintf(s, "*** AUTOPURGE: Deleted User: #%3.3d %s", nUserNumber, user.GetName());
        sysoplog(s, false);
        deluser(nUserNumber);
      }
    }
    ++nUserNumber;
  } while (nUserNumber <= GetApplication()->GetStatusManager()->GetUserCount());
}
コード例 #6
0
void multimail(int *pnUserNumber, int numu) {
    mailrec m, m1;
    char s[255], s2[81];
    WUser user;

    if (freek1(syscfg.msgsdir) < 10) {
        bout.nl();
        bout << "Sorry, not enough disk space left.\r\n\n";
        return;
    }
    bout.nl();

    int i = 0;
    if (getslrec(session()->GetEffectiveSl()).ability & ability_email_anony) {
        i = anony_enable_anony;
    }
    bout << "|#5Show all recipients in mail? ";
    bool show_all = yesno();
    int j = 0;
    string s1 = StringPrintf("\003""6CC: \003""1");

    m.msg.storage_type = EMAIL_STORAGE;
    strcpy(irt, "Multi-Mail");
    irt_name[0] = 0;
    File::Remove(QUOTES_TXT);
    std::string t;
    inmsg(&m.msg, &t, &i, true, "email", INMSG_FSED, "Multi-Mail", MSGED_FLAG_NONE);
    if (m.msg.stored_as == 0xffffffff) {
        return;
    }
    strcpy(m.title, t.c_str());

    bout <<  "Mail sent to:\r\n";
    sysoplog("Multi-Mail to:");

    lineadd(&m.msg, "\003""7----", "email");

    for (int cv = 0; cv < numu; cv++) {
        if (pnUserNumber[cv] < 0) {
            continue;
        }
        application()->users()->ReadUser(&user, pnUserNumber[cv]);
        if ((user.GetSl() == 255 && (user.GetNumMailWaiting() > (syscfg.maxwaiting * 5))) ||
                ((user.GetSl() != 255) && (user.GetNumMailWaiting() > syscfg.maxwaiting)) ||
                user.GetNumMailWaiting() > 200) {
            bout << user.GetUserNameAndNumber(pnUserNumber[cv]) << " mailbox full, not sent.";
            pnUserNumber[cv] = -1;
            continue;
        }
        if (user.IsUserDeleted()) {
            bout << "User deleted, not sent.\r\n";
            pnUserNumber[cv] = -1;
            continue;
        }
        strcpy(s, "  ");
        user.SetNumMailWaiting(user.GetNumMailWaiting() + 1);
        application()->users()->WriteUser(&user, pnUserNumber[cv]);
        if (pnUserNumber[cv] == 1) {
            ++fwaiting;
        }
        strcat(s, user.GetUserNameAndNumber(pnUserNumber[cv]));
        WStatus* pStatus = application()->GetStatusManager()->BeginTransaction();
        if (pnUserNumber[cv] == 1) {
            pStatus->IncrementNumFeedbackSentToday();
            session()->user()->SetNumFeedbackSentToday(session()->user()->GetNumFeedbackSentToday() + 1);
            session()->user()->SetNumFeedbackSent(session()->user()->GetNumFeedbackSent() + 1);
            ++fsenttoday;
        } else {
            pStatus->IncrementNumEmailSentToday();
            session()->user()->SetNumEmailSent(session()->user()->GetNumEmailSent() + 1);
            session()->user()->SetNumEmailSentToday(session()->user()->GetNumEmailSentToday() + 1);
        }
        application()->GetStatusManager()->CommitTransaction(pStatus);
        sysoplog(s);
        bout << s;
        bout.nl();
        if (show_all) {
            sprintf(s2, "%-22.22s  ", user.GetUserNameAndNumber(pnUserNumber[cv]));
            s1.assign(s2);
            j++;
            if (j >= 3) {
                lineadd(&m.msg, s1, "email");
                j = 0;
                s1 = "\003""1    ";
            }
        }
    }
    if (show_all) {
        if (j) {
            lineadd(&m.msg, s1, "email");
        }
    }
    s1 = StringPrintf("\003""2Mail Sent to %d Addresses!", numu);
    lineadd(&m.msg, "\003""7----", "email");
    lineadd(&m.msg, s1, "email");

    m.anony = static_cast< unsigned char >(i);
    m.fromsys = 0;
    m.fromuser = static_cast<unsigned short>(session()->usernum);
    m.tosys = 0;
    m.touser = 0;
    m.status = status_multimail;
    m.daten = static_cast<unsigned long>(time(nullptr));

    unique_ptr<File> pFileEmail(OpenEmailFile(true));
    int len = pFileEmail->GetLength() / sizeof(mailrec);
    if (len == 0) {
        i = 0;
    } else {
        i = len - 1;
        pFileEmail->Seek(static_cast<long>(i) * sizeof(mailrec), File::seekBegin);
        pFileEmail->Read(&m1, sizeof(mailrec));
        while ((i > 0) && (m1.tosys == 0) && (m1.touser == 0)) {
            --i;
            pFileEmail->Seek(static_cast<long>(i) * sizeof(mailrec), File::seekBegin);
            int i1 = pFileEmail->Read(&m1, sizeof(mailrec));
            if (i1 == -1) {
                bout << "|#6DIDN'T READ WRITE!\r\n";
            }
        }
        if ((m1.tosys) || (m1.touser)) {
            ++i;
        }
    }
    pFileEmail->Seek(static_cast<long>(i) * sizeof(mailrec), File::seekBegin);
    for (int cv = 0; cv < numu; cv++) {
        if (pnUserNumber[cv] > 0) {
            m.touser = static_cast<unsigned short>(pnUserNumber[cv]);
            pFileEmail->Write(&m, sizeof(mailrec));
        }
    }
    pFileEmail->Close();
}
コード例 #7
0
int oneuser() {
    char s[81], *ss;
    int nUserNumber, nSystemNumber, i;
    WUser user;

    if (mml_s) {
        if (mml_started) {
            ss = strtok(nullptr, "\r\n");
        } else {
            ss = strtok(mml_s, "\r\n");
        }
        mml_started = 1;
        if (ss == nullptr) {
            free(mml_s);
            mml_s = nullptr;
            return -1;
        }
        strcpy(s, ss);
        for (i = 0; s[i] != 0; i++) {
            s[i] = upcase(s[i]);
        }
    } else {
        bout << "|#2>";
        input(s, 40);
    }
    nUserNumber = finduser1(s);
    if (nUserNumber == 65535) {
        return -1;
    }
    if (s[0] == 0) {
        return -1;
    }
    if (nUserNumber <= 0) {
        bout.nl();
        bout << "Unknown user.\r\n\n";
        return 0;
    }
    nSystemNumber = 0;
    if (ForwardMessage(&nUserNumber, &nSystemNumber)) {
        bout.nl();
        bout << "Forwarded.\r\n\n";
        if (nSystemNumber) {
            bout << "Forwarded to another system.\r\n";
            bout << "Can't send multi-mail to another system.\r\n\n";
            return 0;
        }
    }
    if (nUserNumber == 0) {
        bout.nl();
        bout << "Unknown user.\r\n\n";
        return 0;
    }
    application()->users()->ReadUser(&user, nUserNumber);
    if (((user.GetSl() == 255) && (user.GetNumMailWaiting() > (syscfg.maxwaiting * 5))) ||
            ((user.GetSl() != 255) && (user.GetNumMailWaiting() > syscfg.maxwaiting)) ||
            (user.GetNumMailWaiting() > 200)) {
        bout.nl();
        bout << "Mailbox full.\r\n\n";
        return 0;
    }
    if (user.IsUserDeleted()) {
        bout.nl();
        bout << "Deleted user.\r\n\n";
        return 0;
    }
    bout << "     -> " << user.GetUserNameAndNumber(nUserNumber) << wwiv::endl;
    return nUserNumber;
}
コード例 #8
0
ファイル: sysopf.cpp プロジェクト: bhaggerty/wwiv
void valuser(int nUserNumber) {
  char s[81], s1[81], s2[81], s3[81], ar1[20], dar1[20];

  WUser user;
  GetApplication()->GetUserManager()->ReadUser(&user, nUserNumber);
  if (!user.IsUserDeleted()) {
    GetSession()->bout.NewLine();
    GetSession()->bout << "|#9Name: |#2" << user.GetUserNameAndNumber(nUserNumber) << wwiv::endl;
    GetSession()->bout << "|#9RN  : |#2" << user.GetRealName() << wwiv::endl;
    GetSession()->bout << "|#9PH  : |#2" << user.GetVoicePhoneNumber() << wwiv::endl;
    GetSession()->bout << "|#9Age : |#2" << user.GetAge() << " " << user.GetGender() << wwiv::endl;
    GetSession()->bout << "|#9Comp: |#2" << ctypes(user.GetComputerType()) << wwiv::endl;
    if (user.GetNote()[0]) {
      GetSession()->bout << "|#9Note: |#2" << user.GetNote() << wwiv::endl;
    }
    GetSession()->bout << "|#9SL  : |#2" << user.GetSl() << wwiv::endl;
    if (user.GetSl() != 255 && user.GetSl() < GetSession()->GetEffectiveSl()) {
      GetSession()->bout << "|#9New : ";
      input(s, 3, true);
      if (s[0]) {
        int nSl = atoi(s);
        if (!GetApplication()->GetWfcStatus() && nSl >= GetSession()->GetEffectiveSl()) {
          nSl = -2;
        }
        if (nSl >= 0 && nSl < 255) {
          user.SetSl(nSl);
        }
        if (nSl == -1) {
          GetSession()->bout.NewLine();
          GetSession()->bout << "|#9Delete? ";
          if (yesno()) {
            deluser(nUserNumber);
            GetSession()->bout.NewLine();
            GetSession()->bout << "|#6Deleted.\r\n\n";
          } else {
            GetSession()->bout.NewLine();
            GetSession()->bout << "|#3NOT deleted.\r\n";
          }
          return;
        }
      }
    }
    GetSession()->bout.NewLine();
    GetSession()->bout << "|#9DSL : |#2" << user.GetDsl() << wwiv::endl;
    if (user.GetDsl() != 255 && user.GetDsl() < GetSession()->GetCurrentUser()->GetDsl()) {
      GetSession()->bout << "|#9New ? ";
      input(s, 3, true);
      if (s[0]) {
        int nDsl = atoi(s);
        if (!GetApplication()->GetWfcStatus() && nDsl >= GetSession()->GetCurrentUser()->GetDsl()) {
          nDsl = -1;
        }
        if (nDsl >= 0 && nDsl < 255) {
          user.SetDsl(nDsl);
        }
      }
    }
    strcpy(s3, restrict_string);
    int ar2     = 1;
    int dar2    = 1;
    ar1[0]      = RETURN;
    dar1[0]     = RETURN;
    for (int i = 0; i <= 15; i++) {
      if (user.HasArFlag(1 << i)) {
        s[i] = static_cast<char>('A' + i);
      } else {
        s[i] = SPACE;
      }
      if (GetSession()->GetCurrentUser()->HasArFlag(1 << i)) {
        ar1[ar2++] = static_cast<char>('A' + i);
      }
      if (user.HasDarFlag(1 << i)) {
        s1[i] = static_cast<char>('A' + i);
      } else {
        s1[i] = SPACE;
      }
      if (GetSession()->GetCurrentUser()->HasDarFlag(1 << i)) {
        dar1[dar2++] = static_cast<char>('A' + i);
      }
      if (user.HasRestrictionFlag(1 << i)) {
        s2[i] = s3[i];
      } else {
        s2[i] = SPACE;
      }
    }
    s[16]       = '\0';
    s1[16]      = '\0';
    s2[16]      = '\0';
    ar1[ar2]    = '\0';
    dar1[dar2]  = '\0';
    GetSession()->bout.NewLine();
    char ch1 = '\0';
    if (ar2 > 1) {
      do {
        GetSession()->bout << "|#9AR  : |#2" << s << wwiv::endl;
        GetSession()->bout << "|#9Togl? ";
        ch1 = onek(ar1);
        if (ch1 != RETURN) {
          ch1 -= 'A';
          if (s[ch1] == SPACE) {
            s[ch1] = ch1 + 'A';
          } else {
            s[ch1] = SPACE;
          }
          user.ToggleArFlag(1 << ch1);
          ch1 = 0;
        }
      } while (!hangup && ch1 != RETURN);
    }
    GetSession()->bout.NewLine();
    ch1 = 0;
    if (dar2 > 1) {
      do {
        GetSession()->bout << "|#9DAR : |#2" << s1 << wwiv::endl;
        GetSession()->bout << "|#9Togl? ";
        ch1 = onek(dar1);
        if (ch1 != RETURN) {
          ch1 -= 'A';
          if (s1[ch1] == SPACE) {
            s1[ch1] = ch1 + 'A';
          } else {
            s1[ch1] = SPACE;
          }
          user.ToggleDarFlag(1 << ch1);
          ch1 = 0;
        }
      } while (!hangup && ch1 != RETURN);
    }
    GetSession()->bout.NewLine();
    ch1     = 0;
    s[0]    = RETURN;
    s[1]    = '?';
    strcpy(&(s[2]), restrict_string);
    do {
      GetSession()->bout << "      |#2" << s3 << wwiv::endl;
      GetSession()->bout << "|#9Rstr: |#2" << s2 << wwiv::endl;
      GetSession()->bout << "|#9Togl? ";
      ch1 = onek(s);
      if (ch1 != RETURN && ch1 != SPACE && ch1 != '?') {
        int i = -1;
        for (int i1 = 0; i1 < 16; i1++) {
          if (ch1 == s[i1 + 2]) {
            i = i1;
          }
        }
        if (i > -1) {
          user.ToggleRestrictionFlag(1 << i);
          if (s2[i] == SPACE) {
            s2[i] = s3[i];
          } else {
            s2[i] = SPACE;
          }
        }
        ch1 = 0;
      }
      if (ch1 == '?') {
        ch1 = 0;
        printfile(SRESTRCT_NOEXT);
      }
    } while (!hangup && ch1 == 0);
    GetApplication()->GetUserManager()->WriteUser(&user, nUserNumber);
    GetSession()->bout.NewLine();
  } else {
    GetSession()->bout << "\r\n|#6No Such User.\r\n\n";
  }
}
コード例 #9
0
ファイル: valscan.cpp プロジェクト: bhaggerty/wwiv
void valscan() {
  // Must be local cosysop or better
  if (!lcs()) {
    return;
  }

  int ac = 0;
  int os = GetSession()->GetCurrentMessageArea();

  if (uconfsub[1].confnum != -1 && okconf(GetSession()->GetCurrentUser())) {
    ac = 1;
    tmp_disable_conf(true);
  }
  bool done = false;
  for (int sn = 0; sn < GetSession()->num_subs && !hangup && !done; sn++) {
    if (!iscan(sn)) {
      continue;
    }
    if (GetSession()->GetCurrentReadMessageArea() < 0) {
      return;
    }

    uint32_t sq = qsc_p[sn];

    // Must be sub with validation "on"
    if (!(xsubs[GetSession()->GetCurrentReadMessageArea()].num_nets)
        || !(subboards[GetSession()->GetCurrentReadMessageArea()].anony & anony_val_net)) {
      continue;
    }

    GetSession()->bout.NewLine();
    GetSession()->bout.Color(2);
    GetSession()->bout.ClearEOL();
    GetSession()->bout << "{{ ValScanning " << subboards[GetSession()->GetCurrentReadMessageArea()].name << " }}\r\n";
    lines_listed = 0;
    GetSession()->bout.ClearEOL();
    if (okansi() && !newline) {
      GetSession()->bout << "\r\x1b[2A";
    }

    for (int i = 1; i <= GetSession()->GetNumMessagesInCurrentMessageArea() && !hangup && !done; i++) {    // was i = 0
      if (get_post(i)->status & status_pending_net) {
        CheckForHangup();
        GetSession()->localIO()->tleft(true);
        if (i > 0 && i <= GetSession()->GetNumMessagesInCurrentMessageArea()) {
          bool next;
          int val;
          read_message(i, &next, &val);
          GetSession()->bout << "|#4[|#4Subboard: " << subboards[GetSession()->GetCurrentReadMessageArea()].name << "|#1]\r\n";
          GetSession()->bout <<  "|#1D|#9)elete, |#1R|#9)eread |#1V|#9)alidate, |#1M|#9)ark Validated, |#1Q|#9)uit: |#2";
          char ch = onek("QDVMR");
          switch (ch) {
          case 'Q':
            done = true;
            break;
          case 'R':
            i--;
            continue;
          case 'V': {
            open_sub(true);
            resynch(&i, nullptr);
            postrec *p1 = get_post(i);
            p1->status &= ~status_pending_net;
            write_post(i, p1);
            close_sub();
            send_net_post(p1, subboards[GetSession()->GetCurrentReadMessageArea()].filename,
                          GetSession()->GetCurrentReadMessageArea());
            GetSession()->bout.NewLine();
            GetSession()->bout << "|#7Message sent.\r\n\n";
          }
          break;
          case 'M':
            if (lcs() && i > 0 && i <= GetSession()->GetNumMessagesInCurrentMessageArea() &&
                subboards[GetSession()->GetCurrentReadMessageArea()].anony & anony_val_net &&
                xsubs[GetSession()->GetCurrentReadMessageArea()].num_nets) {
              open_sub(true);
              resynch(&i, nullptr);
              postrec *p1 = get_post(i);
              p1->status &= ~status_pending_net;
              write_post(i, p1);
              close_sub();
              GetSession()->bout.NewLine();
              GetSession()->bout << "|#9Not set for net pending now.\r\n\n";
            }
            break;
          case 'D':
            if (lcs()) {
              if (i > 0) {
                open_sub(true);
                resynch(&i, nullptr);
                postrec p2 = *get_post(i);
                delete_message(i);
                close_sub();
                if (p2.ownersys == 0) {
                  WUser tu;
                  GetApplication()->GetUserManager()->ReadUser(&tu, p2.owneruser);
                  if (!tu.IsUserDeleted()) {
                    if (static_cast<unsigned long>(date_to_daten(tu.GetFirstOn())) < p2.daten) {
                      GetSession()->bout.NewLine();
                      GetSession()->bout << "|#2Remove how many posts credit? ";
                      char szNumCredits[ 11 ];
                      input(szNumCredits, 3, true);
                      int nNumPostCredits = 1;
                      if (szNumCredits[0]) {
                        nNumPostCredits = atoi(szNumCredits);
                      }
                      nNumPostCredits = std::min<int>(tu.GetNumMessagesPosted(), nNumPostCredits);
                      if (nNumPostCredits) {
                        tu.SetNumMessagesPosted(tu.GetNumMessagesPosted() - static_cast<unsigned short>(nNumPostCredits));
                      }
                      GetSession()->bout.NewLine();
                      GetSession()->bout << "|#3Post credit removed = " << nNumPostCredits << wwiv::endl;
                      tu.SetNumDeletedPosts(tu.GetNumDeletedPosts() + 1);
                      GetApplication()->GetUserManager()->WriteUser(&tu, p2.owneruser);
                      GetApplication()->UpdateTopScreen();
                    }
                  }
                }
                resynch(&i, &p2);
              }
            }
            break;
          }
        }
      }
    }
    qsc_p[sn] = sq;
  }

  if (ac) {
    tmp_disable_conf(false);
  }

  GetSession()->SetCurrentMessageArea(os);
  GetSession()->bout.NewLine(2);
}
コード例 #10
0
ファイル: bbs.cpp プロジェクト: bhaggerty/wwiv-1
int WApplication::LocalLogon() {
  session()->localIO()->LocalGotoXY(2, 23);
  bout << "|#9Log on to the BBS?";
  double d = timer();
  int lokb = 0;
  while (!session()->localIO()->LocalKeyPressed() && (fabs(timer() - d) < SECONDS_PER_MINUTE_FLOAT))
    ;

  if (session()->localIO()->LocalKeyPressed()) {
    char ch = wwiv::UpperCase<char>(session()->localIO()->LocalGetChar());
    if (ch == 'Y') {
      session()->localIO()->LocalPuts(YesNoString(true));
      bout << wwiv::endl;
      lokb = 1;
    } else if (ch == 0 || static_cast<unsigned char>(ch) == 224) {
      // The ch == 224 is a Win32'ism
      session()->localIO()->LocalGetChar();
    } else {
      bool fast = false;
      if (!AllowLocalSysop()) {
        return lokb;
      }

      if (ch == 'F') {   // 'F' for Fast
        m_unx = 1;
        fast = true;
      } else {
        switch (ch) {
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
          fast = true;
          m_unx = ch - '0';
          break;
        }
      }
      if (!fast || m_unx > GetStatusManager()->GetUserCount()) {
        return lokb;
      }

      WUser tu;
      users()->ReadUserNoCache(&tu, m_unx);
      if (tu.GetSl() != 255 || tu.IsUserDeleted()) {
        return lokb;
      }

      session()->usernum = m_unx;
      int nSavedWFCStatus = GetWfcStatus();
      SetWfcStatus(0);
      session()->ReadCurrentUser();
      read_qscn(session()->usernum, qsc, false);
      SetWfcStatus(nSavedWFCStatus);
      bputch(ch);
      session()->localIO()->LocalPuts("\r\n\r\n\r\n\r\n\r\n\r\n");
      lokb = 2;
      session()->ResetEffectiveSl();
      changedsl();
      if (!set_language(session()->user()->GetLanguage())) {
        session()->user()->SetLanguage(0);
        set_language(0);
      }
      return lokb;
    }
    if (ch == 0 || static_cast<unsigned char>(ch) == 224) {
      // The 224 is a Win32'ism
      session()->localIO()->LocalGetChar();
    }
  }
  if (lokb == 0) {
    session()->localIO()->LocalCls();
  }
  return lokb;
}
コード例 #11
0
ファイル: users.cpp プロジェクト: venom49637/wwiv
int FixUsersCommand::Execute() {
    std::cout << "Runnning FixUsersCommand::Execute" << std::endl;
    	File userFile(syscfg.datadir, USER_LST);
	if(!userFile.Exists()) {
		Print(NOK, true, "%s does not exist.", userFile.full_pathname().c_str());
		giveUp();
	}

	WUserManager userMgr;
	userMgr.InitializeUserManager(syscfg.datadir, sizeof(userrec), syscfg.maxusers);
	Print(OK, true, "Checking USER.LST... found %d user records.", userMgr.GetNumberOfUserRecords());

	Print(OK, true, "TBD: Check for trashed user recs.");
	if(userMgr.GetNumberOfUserRecords() > syscfg.maxusers) {
		Print(OK, true, "Might be too many.");
			maybeGiveUp();
	} else {
		Print(OK, true, "Reasonable number.");
	}

	std::vector<smalrec> smallrecords;
	std::set<std::string> names;

  const int num_user_records = userMgr.GetNumberOfUserRecords();
	for(int i = 1; i <= num_user_records; i++) {
		WUser user;
		userMgr.ReadUser(&user, i);
		user.FixUp();
		userMgr.WriteUser(&user, i);
		if (!user.IsUserDeleted() && !user.IsUserInactive()) {
			smalrec sr = { 0 };
			strcpy((char*) sr.name, user.GetName());
			sr.number = static_cast<unsigned short>(i);
			std::string namestring((char*) sr.name);
			if (names.find(namestring) == names.end()) {
				smallrecords.push_back(sr);
				names.insert(namestring);
        const std::string msg = StringPrintf("Keeping user: %s #%d", sr.name, sr.number);
        Print(OK, true, msg.c_str());
			}
			else {
				std::cout << "[skipping duplicate user: "******" #" << sr.number << "]";
			}
		}
	};

	std::sort(smallrecords.begin(), smallrecords.end(), [](const smalrec& a, const smalrec& b) -> bool {
		int equal = strcmp((char*)a.name, (char*)b.name);

		// Sort by user number if names match.
		if (equal == 0) {
			return a.number < b.number;
		}

		// Otherwise sort by name comparison.
		return equal < 0;
	});

	printf("size=%lu %lu\n", smallrecords.size(), sizeof(smalrec) * smallrecords.size());

	Print(OK, true, "Checking NAMES.LST");
	File nameFile(syscfg.datadir, NAMES_LST);
	if(!nameFile.Exists()) {
		Print(NOK, true, "%s does not exist, regenerating with %d names", nameFile.full_pathname().c_str(),
			smallrecords.size());
		nameFile.Close();
		nameFile.Open(File::modeCreateFile | File::modeBinary | File::modeWriteOnly);
		nameFile.Write(&smallrecords[0], sizeof(smalrec) * smallrecords.size());
		nameFile.Close();

	} else {
		if(nameFile.Open(File::modeReadOnly | File::modeBinary)) {
			unsigned long size = nameFile.GetLength();
			unsigned short recs = static_cast<unsigned short>(size / sizeof(smalrec));
			if (recs != status.users) {
				status.users = recs;
				Print(NOK, true, "STATUS.DAT contained an incorrect user count.");
			} else {
				Print(OK, true, "STATUS.DAT matches expected user count of %d users.", status.users);
			}
		}
		nameFile.Close();
	}
    return 0;
}