コード例 #1
0
ファイル: chat.cpp プロジェクト: venom49637/wwiv
void ch_direct(const char *pszMessage, int loc, char *pszColorString, int node, int nOffSet) {
    if (strlen(pszMessage + nOffSet) == 0) {
        bout << "|#1[|#9Message required after using a / or > command.|#1]\r\n";
        return;
    }

    instancerec ir;
    get_inst_info(node, &ir);
    char szMessage[ 512 ];
    if (ir.loc == loc) {
        if (!strlen(pszMessage + nOffSet)) {
            bout << "|#1[|#9Message required after using a / or > command.|#1]\r\n";
            return;
        }
        WUser u;
        application()->users()->ReadUser(&u, ir.user);
        char szUserName[ 81 ];
        strcpy(szUserName, u.GetName());
        sprintf(szMessage, "|#9From %.12s|#6 [to %s]|#1: %s%s",
                session()->user()->GetName(), szUserName, pszColorString,
                pszMessage + nOffSet + 1);
        for (int i = 1; i <= num_instances(); i++) {
            get_inst_info(i, &ir);
            if (ir.loc == loc &&  i != application()->GetInstanceNumber()) {
                send_inst_str(i, szMessage);
            }
        }
        bout << "|#1[|#9Message directed to " << szUserName << "|#1\r\n";
    } else {
        bout << szMessage;
        bout.nl();
    }
}
コード例 #2
0
ファイル: wfc.cpp プロジェクト: bhaggerty/wwiv
void wfc_update() {
  if (!GetApplication()->HasConfigFlag(OP_FLAGS_WFC_SCREEN)) {
    return;
  }

  instancerec ir;
  WUser u;

  get_inst_info(inst_num, &ir);
  GetApplication()->GetUserManager()->ReadUserNoCache(&u, ir.user);
  GetSession()->localIO()->LocalXYAPrintf(57, 18, 15, "%-3d", inst_num);
  if (ir.flags & INST_FLAGS_ONLINE) {
    GetSession()->localIO()->LocalXYAPrintf(42, 19, 14, "%-25.25s", u.GetUserNameAndNumber(ir.user));
  } else {
    GetSession()->localIO()->LocalXYAPrintf(42, 19, 14, "%-25.25s", "Nobody");
  }

  char szBuffer[ 255 ];
  szBuffer[0] = '\0';
  make_inst_str(inst_num, szBuffer, INST_FORMAT_WFC);
  GetSession()->localIO()->LocalXYAPrintf(42, 20, 14, "%-25.25s", szBuffer);
  if (num_instances() > 1) {
    do {
      ++inst_num;
      if (inst_num > num_instances()) {
        inst_num = 1;
      }
    } while (inst_num == GetApplication()->GetInstanceNumber());
  }
}
コード例 #3
0
ファイル: menu.cpp プロジェクト: insidenothing/wwiv
bool LoadMenuSetup(int user_number) {
  if (!pSecondUserRec) {
    MenuSysopLog("Mem Error");
    return false;
  }
  UnloadMenuSetup();

  if (!user_number) {
    return false;
  }
  File userConfig(syscfg.datadir, CONFIG_USR);
  if (!userConfig.Exists()) {
    return false;
  }
  WUser user;
  application()->users()->ReadUser(&user, user_number);
  if (userConfig.Open(File::modeReadOnly | File::modeBinary)) {
    userConfig.Seek(user_number * sizeof(user_config), File::seekBegin);

    int len = userConfig.Read(pSecondUserRec, sizeof(user_config));
    userConfig.Close();

    if (len != sizeof(user_config) || !IsEqualsIgnoreCase(reinterpret_cast<char*>(pSecondUserRec->name), user.GetName())) {
      memset(pSecondUserRec, 0, sizeof(user_config));
      strcpy(reinterpret_cast<char*>(pSecondUserRec->name), user.GetName());
      return 0;
    }
    nSecondUserRecLoaded = user_number;
    return true;
  }
  return false;
}
コード例 #4
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;
  }
}
コード例 #5
0
ファイル: chat.cpp プロジェクト: venom49637/wwiv
// Displays which channel the user is in, who's in the channel with them,
// whether or not the channel is secured, and tells the user how to obtain
// help
void intro(int loc) {
    int nodes[20];

    bout << "|#7You are in " << channels[loc - INST_LOC_CH1 + 1].name << wwiv::endl;
    who_online(nodes, loc);
    if (nodes[0]) {
        for (int i = 1; i <= nodes[0]; i++) {
            WUser u;
            application()->users()->ReadUser(&u, nodes[i]);
            if (((nodes[0] - i) == 1) && (nodes[0] >= 2)) {
                bout << "|#1" << u.GetName() << " |#7and ";
            } else {
                bout << "|#1" << u.GetName() << (((nodes[0] > 1) && (i != nodes[0])) ? "|#7, " : " ");
            }
        }
    }
    if (nodes[0] == 1) {
        bout << "|#7is here with you.\r\n";
    } else if (nodes[0] > 1) {
        bout << "|#7are here with you.\r\n";
    } else {
        bout << "|#7You are the only one here.\r\n";
    }
    char szFileName[ MAX_PATH ];
    sprintf(szFileName, "CHANNEL.%d", (loc + 1 - INST_LOC_CH1));
    if (loc != INST_LOC_CH1 && File::Exists(szFileName)) {
        bout << "|#7This channel is |#1secured|#7.\r\n";
    }
    bout << "|#7Type ? for help.\r\n";
}
コード例 #6
0
ファイル: finduser.cpp プロジェクト: bhaggerty/wwiv
// Takes user name/handle as parameter, and returns user number, if found,
// else returns 0.
int finduser1(const string searchString) {
  if (searchString.empty()) {
    return 0;
  }
  int nFindUserNum = finduser(searchString);
  if (nFindUserNum > 0) {
    return nFindUserNum;
  }

  string userNamePart = searchString;
  StringUpperCase(userNamePart);
  for (int i1 = 0; i1 < GetApplication()->GetStatusManager()->GetUserCount(); i1++) {
    if (strstr(reinterpret_cast<char*>(smallist[i1].name), userNamePart.c_str()) != NULL) {
      int nCurrentUserNum = smallist[i1].number;
      WUser user;
      GetApplication()->GetUserManager()->ReadUser(&user, nCurrentUserNum);
      GetSession()->bout << "|#5Do you mean " << user.GetUserNameAndNumber(nCurrentUserNum) << " (Y/N/Q)? ";
      char ch = ynq();
      if (ch == 'Y') {
        return nCurrentUserNum;
      }
      if (ch == 'Q') {
        return 0;
      }
    }
  }
  return 0;
}
コード例 #7
0
ファイル: chat.cpp プロジェクト: venom49637/wwiv
int wusrinst(char *n) {
    instancerec ir;

    for (int i = 0; i <= num_instances(); i++) {
        get_inst_info(i, &ir);
        if (ir.flags & INST_FLAGS_ONLINE) {
            WUser user;
            application()->users()->ReadUser(&user, ir.user);
            if (IsEqualsIgnoreCase(user.GetName(), n)) {
                return i;
            }
        }
    }
    return 0;
}
コード例 #8
0
ファイル: menu.cpp プロジェクト: insidenothing/wwiv
void WriteMenuSetup(int user_number) {
  if (!user_number) {
    return;
  }

  WUser user;
  application()->users()->ReadUser(&user, user_number);
  strcpy(pSecondUserRec->name, user.GetName());

  File userConfig(syscfg.datadir, CONFIG_USR);
  if (!userConfig.Open(File::modeReadWrite | File::modeBinary | File::modeCreateFile)) {
    return;
  }

  userConfig.Seek(user_number * sizeof(user_config), File::seekBegin);
  userConfig.Write(pSecondUserRec, sizeof(user_config));
  userConfig.Close();
}
コード例 #9
0
ファイル: menu.cpp プロジェクト: bhaggerty/wwiv
void WriteMenuSetup(int nUserNum) {
  if (!nUserNum) {
    return;
  }

  WUser user;
  GetApplication()->GetUserManager()->ReadUser(&user, nUserNum);
  strcpy(pSecondUserRec->name, user.GetName());

  WFile userConfig(syscfg.datadir, CONFIG_USR);
  if (!userConfig.Open(WFile::modeReadWrite | WFile::modeBinary | WFile::modeCreateFile)) {
    return;
  }

  userConfig.Seek(nUserNum * sizeof(user_config), WFile::seekBegin);
  userConfig.Write(pSecondUserRec, sizeof(user_config));
  userConfig.Close();
}
コード例 #10
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);
}
コード例 #11
0
ファイル: newuser.cpp プロジェクト: insidenothing/wwiv
bool check_dupes(const char *pszPhoneNumber) {
  int nUserNumber = find_phone_number(pszPhoneNumber);
  if (nUserNumber && nUserNumber != session()->usernum) {
    char szBuffer[ 255 ];
    sprintf(szBuffer, "    %s entered phone # %s", session()->user()->GetName(), pszPhoneNumber);
    sysoplog(szBuffer, false);
    ssm(1, 0, szBuffer);

    WUser user;
    application()->users()->ReadUser(&user, nUserNumber);
    sprintf(szBuffer, "      also entered by %s", user.GetName());
    sysoplog(szBuffer, false);
    ssm(1, 0, szBuffer);

    return true;
  }

  return false;
}
コード例 #12
0
ファイル: inetmsg.cpp プロジェクト: bhaggerty/wwiv
char *read_inet_addr(char *pszInternetEmailAddress, int nUserNumber) {
  if (!nUserNumber) {
    return NULL;
  }

  if (nUserNumber == GetSession()->usernum && check_inet_addr(GetSession()->GetCurrentUser()->GetEmailAddress())) {
    strcpy(pszInternetEmailAddress, GetSession()->GetCurrentUser()->GetEmailAddress());
  } else {
    //pszInternetEmailAddress = NULL;
    *pszInternetEmailAddress = 0;
    WFile inetAddrFile(syscfg.datadir, INETADDR_DAT);
    if (!inetAddrFile.Exists()) {
      inetAddrFile.Open(WFile::modeReadWrite | WFile::modeBinary | WFile::modeCreateFile, WFile::shareUnknown,
                        WFile::permReadWrite);
      for (int i = 0; i <= syscfg.maxusers; i++) {
        long lCurPos = 80L * static_cast<long>(i);
        inetAddrFile.Seek(lCurPos, WFile::seekBegin);
        inetAddrFile.Write(pszInternetEmailAddress, 80L);
      }
    } else {
      char szUserName[ 255 ];
      inetAddrFile.Open(WFile::modeReadOnly | WFile::modeBinary);
      long lCurPos = 80L * static_cast<long>(nUserNumber);
      inetAddrFile.Seek(lCurPos, WFile::seekBegin);
      inetAddrFile.Read(szUserName, 80L);
      if (check_inet_addr(szUserName)) {
        strcpy(pszInternetEmailAddress, szUserName);
      } else {
        sprintf(pszInternetEmailAddress, "User #%d", nUserNumber);
        WUser user;
        GetApplication()->GetUserManager()->ReadUser(&user, nUserNumber);
        user.SetEmailAddress("");
        GetApplication()->GetUserManager()->WriteUser(&user, nUserNumber);
      }
    }
    inetAddrFile.Close();
  }
  return pszInternetEmailAddress;
}
コード例 #13
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;
    }
  }
}
コード例 #14
0
ファイル: multinst.cpp プロジェクト: venom49637/wwiv
/*
 * Builds a string (in pszOutInstanceString) like:
 *
 * Instance   1: Offline
 *     LastUser: Sysop #1
 *
 * or
 *
 * Instance  22: Network transmission
 *     CurrUser: Sysop #1
 */
void make_inst_str(int nInstanceNum, std::string *out, int nInstanceFormat) {
  const string s = StringPrintf("|#1Instance %-3d: |#2", nInstanceNum);

  instancerec ir;
  get_inst_info(nInstanceNum, &ir);

  const string activity_string = GetInstanceActivityString(ir);

  switch (nInstanceFormat) {
  case INST_FORMAT_WFC:
    out->assign(activity_string); // WFC addition
    break;
  case INST_FORMAT_OLD:
    // Not used anymore.
    out->assign(s);
    break;
  case INST_FORMAT_LIST: {
    std::string userName;
    if (ir.user < syscfg.maxusers && ir.user > 0) {
      WUser user;
      application()->users()->ReadUser(&user, ir.user);
      if (ir.flags & INST_FLAGS_ONLINE) {
        userName = user.GetUserNameAndNumber(ir.user);
      } else {
        userName = "******";
        userName += user.GetUserNameAndNumber(ir.user);
      }
    } else {
      userName = "******";
    }
    out->assign(StringPrintf("|#5%-4d |#2%-35.35s |#1%-37.37s", nInstanceNum, userName.c_str(), activity_string.c_str()));
  }
  break;
  default:
    out->assign(StringPrintf("** INVALID INSTANCE FORMAT PASSED [%d] **", nInstanceFormat));
    break;
  }
}
コード例 #15
0
ファイル: chat.cpp プロジェクト: venom49637/wwiv
// This function is called when a / sign is encountered at the beginning of
//   a message, used for whispering
void ch_whisper(const char *pszMessage, char *pszColorString, int node, int nOffSet) {
    if (strlen(pszMessage + nOffSet) == 0) {
        bout << "|#1[|#9Message required after using a / or > command.|#1]\r\n";
        return;
    }
    if (!node) {
        return;
    }
    instancerec ir;
    get_inst_info(node, &ir);

    char szText[ 512 ];
    if (ir.loc >= INST_LOC_CH1 && ir.loc <= INST_LOC_CH10) {
        sprintf(szText, "|#9From %.12s|#6 [WHISPERED]|#2|#1:%s%s", session()->user()->GetName(), pszColorString,
                pszMessage + nOffSet);
    } else {
        strcpy(szText, pszMessage + nOffSet);
    }
    send_inst_str(node, szText);
    WUser u;
    application()->users()->ReadUser(&u, ir.user);
    bout << "|#1[|#9Message sent only to " << u.GetName() << "|#1]\r\n";
}
コード例 #16
0
ファイル: sysopf.cpp プロジェクト: bhaggerty/wwiv
void set_user_age() {
  std::unique_ptr<WStatus> pStatus(GetApplication()->GetStatusManager()->GetStatus());
  int nUserNumber = 1;
  do {
    WUser user;
    GetApplication()->GetUserManager()->ReadUser(&user, nUserNumber);
    int nAge = years_old(user.GetBirthdayMonth(), user.GetBirthdayDay(), user.GetBirthdayYear());
    if (nAge != user.GetAge()) {
      user.SetAge(nAge);
      GetApplication()->GetUserManager()->WriteUser(&user, nUserNumber);
    }
    ++nUserNumber;
  } while (nUserNumber <= pStatus->GetNumUsers());
}
コード例 #17
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);
}
コード例 #18
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());
}
コード例 #19
0
ファイル: chains.cpp プロジェクト: bhaggerty/wwiv-1
// Displays the list of chains to a user
static void show_chains(int *mapp, int *map) {
  bout.Color(0);
  bout.cls();
  bout.nl();
  bool abort = false;
  bool next = false;
  if (application()->HasConfigFlag(OP_FLAGS_CHAIN_REG) && chains_reg) {
    pla(StringPrintf("|#5  Num |#1%-42.42s|#2%-22.22s|#1%-5.5s", "Description", "Sponsored by", "Usage"), &abort);

    if (okansi()) {
      pla(StringPrintf("|#%d %s", FRAME_COLOR,
              "\xDA\xC4\xC4\xC4\xC2\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC2\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC2\xC4\xC4\xC4\xC4\xC4\xBF"), &abort);
    } else {
      pla(StringPrintf(" +---+-----------------------------------------+---------------------+-----+"), &abort);
    }
    for (int i = 0; i < *mapp && !abort && !hangup; i++) {
      WUser user;
      if (okansi()) {
        application()->users()->ReadUser(&user, chains_reg[map[i]].regby[0]);
        pla(StringPrintf(" |#%d\xB3|#5%3d|#%d\xB3|#1%-41s|#%d\xB3|%2.2d%-21s|#%d\xB3|#1%5d|#%d\xB3",
                FRAME_COLOR,
                i + 1,
                FRAME_COLOR,
                chains[map[i]].description,
                FRAME_COLOR,
                (chains_reg[map[i]].regby[0]) ? 14 : 13,
                (chains_reg[map[i]].regby[0]) ? user.GetName() : "Available",
                FRAME_COLOR,
                chains_reg[map[i]].usage,
                FRAME_COLOR), &abort);
        if (chains_reg[map[i]].regby[0] != 0) {
          for (int i1 = 1; i1 < 5 && !abort; i1++) {
            if (chains_reg[map[i]].regby[i1] != 0) {
              application()->users()->ReadUser(&user, chains_reg[map[i]].regby[i1]);
              pla(StringPrintf(" |#%d\xB3   \xBA%-41s\xB3|#2%-21s|#%d\xB3%5.5s\xB3",
                      FRAME_COLOR, " ", user.GetName(), FRAME_COLOR, " "), &abort);
            }
          }
        }
      } else {
        application()->users()->ReadUser(&user, chains_reg[map[i]].regby[0]);
        pla(StringPrintf(" |%3d|%-41.41s|%-21.21s|%5d|",
                i + 1, chains[map[i]].description,
                (chains_reg[map[i]].regby[0]) ? user.GetName() : "Available",
                chains_reg[map[i]].usage), &abort);
        if (chains_reg[map[i]].regby[0] != 0) {
          for (int i1 = 1; i1 < 5; i1++) {
            if (chains_reg[map[i]].regby[i1] != 0) {
              application()->users()->ReadUser(&user, chains_reg[map[i]].regby[i1]);
              pla(StringPrintf(" |   |                                         |%-21.21s|     |",
                      (chains_reg[map[i]].regby[i1]) ? user.GetName() : "Available"), &abort);
            }
          }
        }
      }
    }
    if (okansi()) {
      pla(StringPrintf("|#%d %s", FRAME_COLOR, "\xC0\xC4\xC4\xC4\xC1\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC1\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC1\xC4\xC4\xC4\xC4\xC4\xD9"), &abort);
    } else {
      pla(StringPrintf(" +---+-----------------------------------------+---------------------+-----+"), &abort);
    }
  } else {
    bout.litebar(" %s Online Programs ", syscfg.systemname);
    bout << "|#7\xDA\xC4\xC4\xC2\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC2\xC4\xC4\xC2\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xBF\r\n";
    for (int i = 0; i < *mapp && !abort && !hangup; i++) {
      osan(StringPrintf("|#7\xB3|#2%2d|#7\xB3 |#1%-33.33s|#7\xB3", i + 1, chains[map[i]].description), &abort, &next);
      i++;
      if (!abort && !hangup) {
        if (i >= *mapp) {
          pla(StringPrintf("  |#7\xB3                                  |#7\xB3"), &abort);
        } else {
          pla(StringPrintf("|#2%2d|#7\xB3 |#1%-33.33s|#7\xB3", i + 1, chains[map[i]].description), &abort);
        }
      }
    }
    bout << "|#7\xC0\xC4\xC4\xC1\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC1\xC4\xC4\xC1\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xD9\r\n";
  }
}
コード例 #20
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();
}
コード例 #21
0
void slash_e() {
    int nUserNumber[MAX_LIST], numu, i, i1;
    char s[81], ch, *sss;
    bool bFound = false;
    WFindFile fnd;

    mml_s = nullptr;
    mml_started = 0;
    if (freek1(syscfg.msgsdir) < 10) {
        bout.nl();
        bout << "Sorry, not enough disk space left.\r\n\n";
        return;
    }
    if (((fsenttoday >= 5) || (session()->user()->GetNumFeedbackSentToday() >= 10) ||
            (session()->user()->GetNumEmailSentToday() >= getslrec(session()->GetEffectiveSl()).emails))
            && (!cs())) {
        bout << "Too much mail sent today.\r\n\n";
        return;
    }
    if (session()->user()->IsRestrictionEmail()) {
        bout << "You can't send mail.\r\n";
        return;
    }
    bool done = false;
    numu = 0;
    do {
        bout.nl(2);
        bout << "|#2Multi-Mail: A,M,D,L,E,Q,? : ";
        ch = onek("QAMDEL?");
        switch (ch) {
        case '?':
            printfile(MMAIL_NOEXT);
            break;
        case 'Q':
            done = true;
            break;
        case 'A':
            bout.nl();
            bout << "Enter names/numbers for users, one per line, max 20.\r\n\n";
            mml_s = nullptr;
            add_list(nUserNumber, &numu, MAX_LIST, so());
            break;
        case 'M': {
            sprintf(s, "%s*.MML", syscfg.datadir);
            bFound = fnd.open(s, 0);
            if (bFound) {
                bout.nl();
                bout << "No mailing lists available.\r\n\n";
                break;
            }
            bout.nl();
            bout << "Available mailing lists:\r\n\n";
            while (bFound) {
                strcpy(s, fnd.GetFileName());
                sss = strchr(s, '.');
                if (sss) {
                    *sss = 0;
                }
                bout << s;
                bout.nl();

                bFound = fnd.next();
            }

            bout.nl();
            bout << "|#2Which? ";
            input(s, 8);

            File fileMailList(syscfg.datadir, s);
            if (!fileMailList.Open(File::modeBinary | File::modeReadOnly)) {
                bout.nl();
                bout << "Unknown mailing list.\r\n\n";
            } else {
                i1 = fileMailList.GetLength();
                mml_s = static_cast<char *>(BbsAllocA(i1 + 10L));
                fileMailList.Read(mml_s, i1);
                mml_s[i1] = '\n';
                mml_s[i1 + 1] = 0;
                fileMailList.Close();
                mml_started = 0;
                add_list(nUserNumber, &numu, MAX_LIST, so());
                if (mml_s) {
                    free(mml_s);
                    mml_s = nullptr;
                }
            }
        }
        break;
        case 'E':
            if (!numu) {
                bout.nl();
                bout << "Need to specify some users first - use A or M\r\n\n";
            } else {
                multimail(nUserNumber, numu);
                done = true;
            }
            break;
        case 'D':
            if (numu) {
                bout.nl();
                bout << "|#2Delete which? ";
                input(s, 2);
                i = atoi(s);
                if ((i > 0) && (i <= numu)) {
                    --numu;
                    for (i1 = i - 1; i1 < numu; i1++) {
                        nUserNumber[i1] = nUserNumber[i1 + 1];
                    }
                }
            }
            break;
        case 'L':
            for (i = 0; i < numu; i++) {
                WUser user;
                application()->users()->ReadUser(&user, nUserNumber[i]);
                bout << i + 1 << ". " << user.GetUserNameAndNumber(nUserNumber[i]) << wwiv::endl;
            }
            break;
        }
        CheckForHangup();
    } while (!done && !hangup);
}
コード例 #22
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;
}
コード例 #23
0
ファイル: sysopf.cpp プロジェクト: bhaggerty/wwiv
void mailr() {
  mailrec m, m1;
  filestatusrec fsr;

  WFile *pFileEmail = OpenEmailFile(false);
  WWIV_ASSERT(pFileEmail);
  if (pFileEmail->IsOpen()) {
    int nRecordNumber = pFileEmail->GetLength() / sizeof(mailrec) - 1;
    char c = ' ';
    while (nRecordNumber >= 0 && c != 'Q' && !hangup) {
      pFileEmail->Seek(nRecordNumber * sizeof(mailrec), WFile::seekBegin);
      pFileEmail->Read(&m, sizeof(mailrec));
      if (m.touser != 0) {
        pFileEmail->Close();
        do {
          WUser user;
          GetApplication()->GetUserManager()->ReadUser(&user, m.touser);
          GetSession()->bout << "|#1  To|#7: |#" << GetSession()->GetMessageColor() << user.GetUserNameAndNumber(
                               m.touser) << wwiv::endl;
          int tp = 80;
          int nn = 0;
          if (m.status & status_source_verified) {
            tp -= 2;
          }
          if (m.status & status_new_net) {
            tp -= 1;
            if (wwiv::strings::GetStringLength(m.title) <= tp) {
              nn = m.title[tp + 1];
            } else {
              nn = 0;
            }
          } else {
            nn = 0;
          }
          set_net_num(nn);
          GetSession()->bout << "|#1Subj|#7: |#" << GetSession()->GetMessageColor() << m.title << wwiv::endl;
          if (m.status & status_file) {
            WFile attachDat(syscfg.datadir, ATTACH_DAT);
            if (attachDat.Open(WFile::modeReadOnly | WFile::modeBinary, WFile::shareUnknown, WFile::permReadWrite)) {
              bool found = false;
              long lAttachFileSize = attachDat.Read(&fsr, sizeof(fsr));
              while (lAttachFileSize > 0 && !found) {
                if (m.daten == static_cast<unsigned long>(fsr.id)) {
                  GetSession()->bout << "|#1Filename|#0.... |#2" << fsr.filename << " (" << fsr.numbytes << " bytes)|#0\r\n";
                  found = true;
                }
                if (!found) {
                  lAttachFileSize = attachDat.Read(&fsr, sizeof(fsr));
                }
              }
              if (!found) {
                GetSession()->bout << "|#1Filename|#0.... |#2File : Unknown or Missing|#0\r\n";
              }
              attachDat.Close();
            } else {
              GetSession()->bout << "|#1Filename|#0.... |#2|#2File : Unknown or Missing|#0\r\n";
            }
          }
          bool next;
          read_message1(&(m.msg), (char)(m.anony & 0x0f), true, &next, "email", m.fromsys, m.fromuser);
          GetSession()->bout << "|#2R,D,Q,<space>  : ";
          if (next) {
            c = ' ';
          } else {
            c = onek("QRD ");
          }
          if (c == 'D') {
            pFileEmail = OpenEmailFile(true);
            pFileEmail->Seek(nRecordNumber * sizeof(mailrec), WFile::seekBegin);
            pFileEmail->Read(&m1, sizeof(mailrec));
            if (memcmp(&m, &m1, sizeof(mailrec)) == 0) {
              delmail(pFileEmail, nRecordNumber);
              bool found = false;
              if (m.status & status_file) {
                WFile attachFile(syscfg.datadir, ATTACH_DAT);
                if (attachFile.Open(WFile::modeReadWrite | WFile::modeBinary)) {
                  long lAttachFileSize = attachFile.Read(&fsr, sizeof(fsr));
                  while (lAttachFileSize > 0 && !found) {
                    if (m.daten == static_cast<unsigned long>(fsr.id)) {
                      found = true;
                      fsr.id = 0;
                      attachFile.Seek(static_cast<long>(sizeof(filestatusrec)) * -1L, WFile::seekCurrent);
                      attachFile.Write(&fsr, sizeof(filestatusrec));
                      WFile::Remove(GetApplication()->GetAttachmentDirectory().c_str(), fsr.filename);
                    } else {
                      attachFile.Read(&fsr, sizeof(filestatusrec));
                    }
                  }
                  attachFile.Close();
                }
              }
            } else {
              GetSession()->bout << "Mail file changed; try again.\r\n";
            }
            pFileEmail->Close();
            if (!GetSession()->IsUserOnline() && m.touser == 1 && m.tosys == 0) {
              GetSession()->GetCurrentUser()->SetNumMailWaiting(GetSession()->GetCurrentUser()->GetNumMailWaiting() - 1);
            }
          }
          GetSession()->bout.NewLine(2);
        } while ((c == 'R') && (!hangup));

        pFileEmail = OpenEmailFile(false);
        WWIV_ASSERT(pFileEmail);
        if (!pFileEmail->IsOpen()) {
          break;
        }
      }
      nRecordNumber -= 1;
    }
    pFileEmail->Close();
  }
  delete pFileEmail;
}
コード例 #24
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";
  }
}
コード例 #25
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;
}
コード例 #26
0
ファイル: wfc.cpp プロジェクト: bhaggerty/wwiv
void wfc_screen() {
  char szBuffer[ 255 ];
  instancerec ir;
  WUser u;
  static double wfc_time = 0, poll_time = 0;

  if (!GetApplication()->HasConfigFlag(OP_FLAGS_WFC_SCREEN)) {
    return;
  }

  int nNumNewMessages = check_new_mail(GetSession()->usernum);
  std::unique_ptr<WStatus> pStatus(GetApplication()->GetStatusManager()->GetStatus());
  if (GetSession()->wfc_status == 0) {
    GetSession()->localIO()->SetCursor(WLocalIO::cursorNone);
    GetSession()->localIO()->LocalCls();
    if (pszScreenBuffer == NULL) {
      pszScreenBuffer = new char[4000];
      WFile wfcFile(syscfg.datadir, WFC_DAT);
      if (!wfcFile.Open(WFile::modeBinary | WFile::modeReadOnly)) {
        wfc_cls();
        std::cout << wfcFile.GetFullPathName() << " NOT FOUND." << std::endl;
        GetApplication()->AbortBBS();
      }
      wfcFile.Read(pszScreenBuffer, 4000);
    }
    DisplayWFCScreen(pszScreenBuffer);
    sprintf(szBuffer, "Activity and Statistics of %s Node %d", syscfg.systemname, GetApplication()->GetInstanceNumber());
    GetSession()->localIO()->LocalXYAPrintf(1 + ((76 - strlen(szBuffer)) / 2), 4, 15, szBuffer);
    GetSession()->localIO()->LocalXYAPrintf(8, 1, 14, fulldate());
    std::string osVersion = WWIV_GetOSVersion();
    GetSession()->localIO()->LocalXYAPrintf(40, 1, 3, "OS: ");
    GetSession()->localIO()->LocalXYAPrintf(44, 1, 14, osVersion.c_str());
    GetSession()->localIO()->LocalXYAPrintf(21, 6, 14, "%d", pStatus->GetNumCallsToday());
    GetSession()->localIO()->LocalXYAPrintf(21, 7, 14, "%d", fwaiting);
    if (nNumNewMessages) {
      GetSession()->localIO()->LocalXYAPrintf(29, 7 , 3, "New:");
      GetSession()->localIO()->LocalXYAPrintf(34, 7 , 12, "%d", nNumNewMessages);
    }
    GetSession()->localIO()->LocalXYAPrintf(21, 8, 14, "%d", pStatus->GetNumUploadsToday());
    GetSession()->localIO()->LocalXYAPrintf(21, 9, 14, "%d", pStatus->GetNumMessagesPostedToday());
    GetSession()->localIO()->LocalXYAPrintf(21, 10, 14, "%d", pStatus->GetNumLocalPosts());
    GetSession()->localIO()->LocalXYAPrintf(21, 11, 14, "%d", pStatus->GetNumEmailSentToday());
    GetSession()->localIO()->LocalXYAPrintf(21, 12, 14, "%d", pStatus->GetNumFeedbackSentToday());
    GetSession()->localIO()->LocalXYAPrintf(21, 13, 14, "%d Mins (%.1f%%)", pStatus->GetMinutesActiveToday(),
                                            100.0 * static_cast<float>(pStatus->GetMinutesActiveToday()) / 1440.0);
    GetSession()->localIO()->LocalXYAPrintf(58, 6, 14, "%s%s", wwiv_version, beta_version);

    GetSession()->localIO()->LocalXYAPrintf(58, 7, 14, "%d", pStatus->GetNetworkVersion());
    GetSession()->localIO()->LocalXYAPrintf(58, 8, 14, "%d", pStatus->GetNumUsers());
    GetSession()->localIO()->LocalXYAPrintf(58, 9, 14, "%ld", pStatus->GetCallerNumber());
    if (pStatus->GetDays()) {
      GetSession()->localIO()->LocalXYAPrintf(58, 10, 14, "%.2f", static_cast<float>(pStatus->GetCallerNumber()) /
                                              static_cast<float>(pStatus->GetDays()));
    } else {
      GetSession()->localIO()->LocalXYAPrintf(58, 10, 14, "N/A");
    }
    GetSession()->localIO()->LocalXYAPrintf(58, 11, 14, sysop2() ? "Available    " : "Not Available");
    if (ok_modem_stuff) {
      GetSession()->localIO()->LocalXYAPrintf(58, 12, 14, "%-20.20s", modem_i->name);
      GetSession()->localIO()->LocalXYAPrintf(58, 13, 14, "%-20s", "Waiting For Call");
    } else {
      GetSession()->localIO()->LocalXYAPrintf(58, 12, 14, "Local %code", (syscfgovr.primaryport) ? 'M' : 'N');
      GetSession()->localIO()->LocalXYAPrintf(58, 13, 14, "Waiting For Command");
    }

    int i = 0, i1 = 0;
    while (GetSession()->wfcdrvs[i] > 0 && GetSession()->wfcdrvs[i] < GetApplication()->GetHomeDir()[0] && i1 < 5) {
      if (iscdrom(static_cast<char>(GetSession()->wfcdrvs[i]))) {
        GetSession()->localIO()->LocalXYAPrintf(2, 16 + i1, 3, "CDROM %c..", GetSession()->wfcdrvs[i] + '@');
        GetSession()->localIO()->LocalXYAPrintf(12 - 1, 17 + i1 - 1, 14, "%10.1f MB", 0.0f);
        i1++;
      } else {
        char szTmpPath[4];
        sprintf(szTmpPath, "%c:\\", GetSession()->wfcdrvs[i] + '@');
        long lFreeDiskSpace = static_cast<long>(freek1(szTmpPath));
        char szTempDiskSize[81];
        if (lFreeDiskSpace > 0) {
          if (lFreeDiskSpace > 2048) {
            sprintf(szTempDiskSize, "%10.1f GB", static_cast<float>(lFreeDiskSpace) / (1024.0 * 1024.0));
          } else {
            sprintf(szTempDiskSize, "%10.1f MB", static_cast<float>(lFreeDiskSpace) / 1024.0);
          }
          GetSession()->localIO()->LocalXYAPrintf(2, 16 + i1, 3, "Drive %c..", GetSession()->wfcdrvs[i] + '@');
          GetSession()->localIO()->LocalXYAPrintf(12 - 1, 17 + i1 - 1, 14, "%s", szTempDiskSize);
          i1++;
        }
      }
      i++;
    }

    get_inst_info(GetApplication()->GetInstanceNumber(), &ir);
    if (ir.user < syscfg.maxusers && ir.user > 0) {
      GetApplication()->GetUserManager()->ReadUserNoCache(&u, ir.user);
      GetSession()->localIO()->LocalXYAPrintf(33, 16, 14, "%-20.20s", u.GetUserNameAndNumber(ir.user));
    } else {
      GetSession()->localIO()->LocalXYAPrintf(33, 16, 14, "%-20.20s", "Nobody");
    }

    GetSession()->wfc_status = 1;
    wfc_update();
    poll_time = wfc_time = timer();
  } else {
    if ((timer() - wfc_time < GetSession()->screen_saver_time) ||
        (GetSession()->screen_saver_time == 0)) {
      GetSession()->localIO()->LocalXYAPrintf(28, 1, 14, times());
      GetSession()->localIO()->LocalXYAPrintf(58, 11, 14, sysop2() ? "Available    " : "Not Available");
      if (timer() - poll_time > 10) {
        wfc_update();
        poll_time = timer();
      }
    } else {
      if ((timer() - poll_time > 10) || GetSession()->wfc_status == 1) {
        GetSession()->wfc_status = 2;
        GetSession()->localIO()->LocalCls();
        GetSession()->localIO()->LocalXYAPrintf(WWIV_GetRandomNumber(38),
                                                WWIV_GetRandomNumber(24),
                                                WWIV_GetRandomNumber(14) + 1,
                                                "WWIV Screen Saver - Press Any Key For WWIV");
        wfc_time = timer() - GetSession()->screen_saver_time - 1;
        poll_time = timer();
      }
    }
  }
}
コード例 #27
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;
}
コード例 #28
0
ファイル: chains.cpp プロジェクト: bhaggerty/wwiv
void show_chains(int *mapp, int *map) {
  char szBuffer[ 255 ];

  GetSession()->bout.Color(0);
  GetSession()->bout.ClearScreen();
  GetSession()->bout.NewLine();
  bool abort = false;
  bool next = false;
  if (GetApplication()->HasConfigFlag(OP_FLAGS_CHAIN_REG) && chains_reg) {
    sprintf(szBuffer, "|#5  Num |#1%-42.42s|#2%-22.22s|#1%-5.5s", "Description", "Sponsored by", "Usage");
    pla(szBuffer, &abort);

    if (okansi()) {
      sprintf(szBuffer, "|#%d %s", FRAME_COLOR,
              "\xDA\xC4\xC4\xC4\xC2\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC2\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC2\xC4\xC4\xC4\xC4\xC4\xBF");
    } else {
      sprintf(szBuffer, " +---+-----------------------------------------+---------------------+-----+");
    }
    pla(szBuffer, &abort);
    for (int i = 0; i < *mapp && !abort && !hangup; i++) {
      WUser user;
      strcat(szBuffer, ". ");
      if (okansi()) {
        GetApplication()->GetUserManager()->ReadUser(&user, chains_reg[map[i]].regby[0]);
        sprintf(szBuffer, " |#%d\xB3|#5%3d|#%d\xB3|#1%-41s|#%d\xB3|%2.2d%-21s|#%d\xB3|#1%5d|#%d\xB3",
                FRAME_COLOR,
                i + 1,
                FRAME_COLOR,
                chains[map[i]].description,
                FRAME_COLOR,
                (chains_reg[map[i]].regby[0]) ? 14 : 13,
                (chains_reg[map[i]].regby[0]) ? user.GetName() : "Available",
                FRAME_COLOR,
                chains_reg[map[i]].usage,
                FRAME_COLOR);
        pla(szBuffer, &abort);
        if (chains_reg[map[i]].regby[0] != 0) {
          for (int i1 = 1; i1 < 5 && !abort; i1++) {
            if (chains_reg[map[i]].regby[i1] != 0) {
              GetApplication()->GetUserManager()->ReadUser(&user, chains_reg[map[i]].regby[i1]);
              sprintf(szBuffer, " |#%d\xB3   \xBA%-41s\xB3|#2%-21s|#%d\xB3%5.5s\xB3",
                      FRAME_COLOR, " ", user.GetName(), FRAME_COLOR, " ");
              pla(szBuffer, &abort);
            }
          }
        }
      } else {
        GetApplication()->GetUserManager()->ReadUser(&user, chains_reg[map[i]].regby[0]);
        sprintf(szBuffer, " |%3d|%-41.41s|%-21.21s|%5d|",
                i + 1, chains[map[i]].description,
                (chains_reg[map[i]].regby[0]) ? user.GetName() : "Available",
                chains_reg[map[i]].usage);
        pla(szBuffer, &abort);
        if (chains_reg[map[i]].regby[0] != 0) {
          for (int i1 = 1; i1 < 5; i1++) {
            if (chains_reg[map[i]].regby[i1] != 0) {
              GetApplication()->GetUserManager()->ReadUser(&user, chains_reg[map[i]].regby[i1]);
              sprintf(szBuffer, " |   |                                         |%-21.21s|     |",
                      (chains_reg[map[i]].regby[i1]) ? user.GetName() : "Available");
              pla(szBuffer, &abort);
            }
          }
        }
      }
    }
    if (okansi()) {
      sprintf(szBuffer, "|#%d %s", FRAME_COLOR,
              "\xC0\xC4\xC4\xC4\xC1\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC1\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC1\xC4\xC4\xC4\xC4\xC4\xD9");
    } else {
      sprintf(szBuffer, " +---+-----------------------------------------+---------------------+-----+");
    }
    pla(szBuffer, &abort);

  } else {
    GetSession()->bout.DisplayLiteBar(" [ %s Online Programs ] ", syscfg.systemname);
    GetSession()->bout <<
                       "|#7\xDA\xC4\xC4\xC2\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC2\xC4\xC4\xC2\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xBF\r\n";
    for (int i = 0; i < *mapp && !abort && !hangup; i++) {
      sprintf(szBuffer, "|#7\xB3|#2%2d|#7\xB3 |#1%-33.33s|#7\xB3", i + 1, chains[map[i]].description);
      osan(szBuffer, &abort, &next);
      i++;
      if (!abort && !hangup) {
        char szBuffer[ 255 ];
        if (i >= *mapp) {
          sprintf(szBuffer, "  |#7\xB3                                  |#7\xB3");
        } else {
          sprintf(szBuffer, "|#2%2d|#7\xB3 |#1%-33.33s|#7\xB3", i + 1, chains[map[i]].description);
        }
        pla(szBuffer, &abort);
      }
    }
    GetSession()->bout <<
                       "|#7\xC0\xC4\xC4\xC1\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC1\xC4\xC4\xC1\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xD9\r\n";
  }
}
コード例 #29
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);
}