예제 #1
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);
}
예제 #2
0
파일: dirlist.cpp 프로젝트: TRI0N/wwiv
/** Displays the available file areas for the current user. */
void dirlist(int mode) {
  bool next   = false;
  int oc      = session()->GetCurrentConferenceFileArea();
  int os      = session()->current_user_dir().subnum;
  int tally   = 0;
  int nd      = 0;
  int sn      = session()->GetCurrentConferenceFileArea();
  int en      = session()->GetCurrentConferenceFileArea();
  bool done   = false;

  do {
    bool is = false;
    bool abort = false;
    int p = 1;
    int i = sn;
    char *ss = nullptr;

    while (i <= en && uconfdir[i].confnum != -1 && !abort) {
      size_t i1 = 0;
      while (i1 < session()->directories.size() && session()->udir[i1].subnum != -1 && !abort) {
        char s[255];
        size_t firstp = 0;
        if (p && mode == 0) {
          p = 0;
          firstp = i1;
          bout.cls();
          if (uconfdir[1].confnum != -1 && okconf(session()->user())) {
            sprintf(s, " [ %s %c ] [ %s ] ", "Conference",
                    dirconfs[uconfdir[i].confnum].designator,
                    stripcolors(reinterpret_cast<char*>(dirconfs[uconfdir[i].confnum].name)));
          } else {
            sprintf(s, " [ %s File Areas ] ", syscfg.systemname);
          }
          bout.litebar(s);
          DisplayHorizontalBar(78, 7);
          bout << "|#2 Dir Qscan?     Directory Name                          Total Files\r\n";
          DisplayHorizontalBar(78, 7);
        }
        ++nd;
        int directory_number = session()->udir[i1].subnum;
        if (directory_number == 0) {
          is = true;
        }
        std::string scanme = "|#6No ";
        if (qsc_n[ directory_number / 32 ] & (1L << (directory_number % 32))) {
          scanme = "|#5Yes";
        }
        dliscan1(directory_number);
        if (session()->current_user_dir().subnum == session()->udir[i1].subnum) {
          sprintf(s, " |#9%3s |#9\xB3 |#6%3s |#9\xB3|B1|15 %-40.40s |#9\xB3 |#9%4d|B0",
                  session()->udir[i1].keys, scanme.c_str(), session()->directories[directory_number].name,
                  session()->numf);
        } else {
          sprintf(s, " |#9%3s |#9\xB3 |#6%3s |#9\xB3 %s%-40.40s |#9\xB3 |#9%4d",
                  session()->udir[i1].keys, scanme.c_str(),
                  (((mode == 1) && (session()->directories[session()->udir[i1].subnum].mask & mask_cdrom)) ? "|#9" : "|#1"),
                  session()->directories[ directory_number ].name, session()->numf);
        }
        if (okansi()) {
          osan(s, &abort, &next);
        } else {
          osan(stripcolors(s), &abort, &next);
        }
        tally += session()->numf;
        int lastp = i1++;
        bout.nl();
        if (bout.lines_listed() >= session()->screenlinest - 2 && mode == 0) {
          p = 1;
          bout.clear_lines_listed();
          DisplayHorizontalBar(78, 7);
          bout.bprintf("|#1Select |#9[|#2%d-%d, [N]ext Page, [Q]uit|#9]|#0 : ",
                                            is ? firstp : firstp + 1, lastp);
          ss = mmkey(1, true);
          if (isdigit(ss[0])) {
            for (size_t i3 = 0; i3 < session()->directories.size(); i3++) {
              if (wwiv::strings::IsEquals(session()->udir[i3].keys, ss)) {
                session()->set_current_user_dir_num(i3);
                os      = session()->current_user_dir().subnum;
                done    = true;
                abort   = true;
              }
            }
          } else {
            switch (ss[0]) {
            case 'Q':
              if (okconf(session()->user())) {
                setuconf(ConferenceType::CONF_DIRS, oc, os);
              }
              done    = true;
              abort   = true;
              break;
            default:
              bout.backline();
              break;
            }
          }
        }
      }
      if (nd) {
        i++;
      }
      if (!okconf(session()->user())) {
        break;
      }
    }
    if (i == 0) {
      pla("None.", &abort);
      bout.nl();
    }
    if (!abort && mode == 0) {
      p = 1;
      DisplayHorizontalBar(78, 7);
      if (okconf(session()->user())) {
        if (uconfdir[1].confnum != -1) {
          bout.bprintf("|#1Select |#9[|#2%d-%d, J=Join Conference, ?=List Again, Q=Quit|#9]|#0 : ",
                                            is ? 0 : 1, is ? nd - 1 : nd);
        } else {
          bout.bprintf("|#1Select |#9[|#2%d-%d, ?=List Again, Q=Quit|#9]|#0 : ", is ? 0 : 1,
                                            is ? nd - 1 : nd);
        }
      } else {
        bout.bprintf("|#1Select |#9[|#2%d-%d, ?=List Again, Q=Quit|#9]|#0 : ", is ? 0 : 1,
                                          is ? nd - 1 : nd);
      }
      ss = mmkey(0, true);
      if (wwiv::strings::IsEquals(ss, "") ||
          wwiv::strings::IsEquals(ss, "Q") ||
          wwiv::strings::IsEquals(ss, "\r")) {
        if (okconf(session()->user())) {
          setuconf(ConferenceType::CONF_DIRS, oc, os);
        }
        done = true;
      }
      if (wwiv::strings::IsEquals(ss, "J")) {
        if (okconf(session()->user())) {
          jump_conf(ConferenceType::CONF_DIRS);
        }
        sn = en = oc = session()->GetCurrentConferenceFileArea();
        nd = i = 0;
        is = false;
      }
      if (isdigit(ss[0])) {
        for (size_t i3 = 0; i3 < session()->directories.size(); i3++) {
          if (wwiv::strings::IsEquals(session()->udir[i3].keys, ss)) {
            session()->set_current_user_dir_num(i3);
            os = session()->current_user_dir().subnum;
            done = true;
          }
        }
      }
      nd = 0;
    } else {
      if (okconf(session()->user())) {
        setuconf(ConferenceType::CONF_DIRS, oc, os);
      }
      done = true;
    }
  } while (!hangup && !done);
}