/** * Reads the auto message */ void read_automessage() { GetSession()->bout.NewLine(); std::unique_ptr<WStatus> status(GetApplication()->GetStatusManager()->GetStatus()); bool bAutoMessageAnonymous = status->IsAutoMessageAnonymous(); WTextFile autoMessageFile(syscfg.gfilesdir, AUTO_MSG, "rt"); std::string line; if (!autoMessageFile.IsOpen() || !autoMessageFile.ReadLine(&line)) { GetSession()->bout << "|#3No auto-message.\r\n"; GetSession()->bout.NewLine(); return; } std::string authorName = StringTrimEnd(line); if (bAutoMessageAnonymous) { if (getslrec(GetSession()->GetEffectiveSl()).ability & ability_read_post_anony) { std::stringstream ss; ss << "<<< " << line << " >>>"; authorName = ss.str(); } else { authorName = ">UNKNOWN<"; } } GetSession()->bout << "\r\n|#9Auto message by: |#2" << authorName << "|#0\r\n\n"; int nLineNumber = 0; while (autoMessageFile.ReadLine(&line) && nLineNumber++ < 10) { StringTrim(line); GetSession()->bout.Color(9); GetSession()->bout << "|#9" << line << wwiv::endl; } GetSession()->bout.NewLine(); }
void get_user_ppp_addr() { GetSession()->internetFullEmailAddress = ""; bool found = false; int nNetworkNumber = getnetnum("FILEnet"); GetSession()->SetNetworkNumber(nNetworkNumber); if (nNetworkNumber == -1) { return; } set_net_num(GetSession()->GetNetworkNumber()); GetSession()->internetFullEmailAddress = wwiv::strings::StringPrintf("%s@%s", GetSession()->internetEmailName.c_str(), GetSession()->internetEmailDomain.c_str()); WTextFile acctFile(GetSession()->GetNetworkDataDirectory(), ACCT_INI, "rt"); char szLine[ 260 ]; if (acctFile.IsOpen()) { while (acctFile.ReadLine(szLine, 255) && !found) { if (WWIV_STRNICMP(szLine, "USER", 4) == 0) { int nUserNum = atoi(&szLine[4]); if (nUserNum == GetSession()->usernum) { char* ss = strtok(szLine, "="); ss = strtok(NULL, "\r\n"); if (ss) { while (ss[0] == ' ') { strcpy(ss, &ss[1]); } StringTrimEnd(ss); if (ss) { GetSession()->internetFullEmailAddress = ss; found = true; } } } } } acctFile.Close(); } if (!found && !GetSession()->internetPopDomain.empty()) { int j = 0; char szLocalUserName[ 255 ]; strcpy(szLocalUserName, GetSession()->GetCurrentUser()->GetName()); for (int i = 0; (i < wwiv::strings::GetStringLength(szLocalUserName)) && (i < 61); i++) { if (szLocalUserName[ i ] != '.') { szLine[ j++ ] = translate_table[(int)szLocalUserName[ i ] ]; } } szLine[ j ] = '\0'; GetSession()->internetFullEmailAddress = wwiv::strings::StringPrintf("%s@%s", szLine, GetSession()->internetPopDomain.c_str()); } }
bool handle_sub_add_drop_resp(Context& context, Packet& p, const std::string& add_or_drop) { // We want to stop at the 1st \0 string subname = p.text.c_str(); StringTrimEnd(&subname); auto b = p.text.begin(); while (b != p.text.end() && *b != '\0') { b++; } if (b == p.text.end()) { LOG(INFO) << "Unable to determine code from add_drop response."; return false; } // NULL b++; if (b == p.text.end()) { LOG(INFO) << "Unable to determine code from add_drop response."; return false; } LOG(INFO) << "Processed " << add_or_drop << " response from system @" << p.nh.fromsys << " to subtype: " << subname; char code = *b++; string code_string = SubAddDropResponseMessage(static_cast<uint8_t>(code)); string message_text = string(b, p.text.end()); net_header_rec nh = {}; string title = StringPrintf("WWIV AreaFix (%s) Response for subtype '%s'", context.net.name, subname.c_str()); string byname = StringPrintf("WWIV AreaFix (%s) @%u", context.net.name, p.nh.fromsys); string body = StringPrintf("SubType '%s', (%s) Response: '%s'\r\n%s\r\n", subname.c_str(), add_or_drop.c_str(), code_string.c_str(), message_text.c_str()); nh.touser = 1; nh.fromuser = std::numeric_limits<uint16_t>::max(); nh.main_type = main_type_email; nh.daten = wwiv::sdk::time_t_to_daten(time(nullptr)); const string filename = create_pend(context.net.dir, true, static_cast<char>('0' + context.network_number)); return send_network_email(filename, context.net, nh, {}, body, byname, title); }
static string daten_to_humantime(uint32_t daten) { time_t t = static_cast<time_t>(daten); string human_date = string(asctime(localtime(&t))); StringTrimEnd(&human_date); return human_date; }
/** * Removes the whitespace from the end of the string * @param pszString The string from which to remove the trailing whitespace */ void StringTrimEnd(char *pszString) { string s(pszString); StringTrimEnd(&s); strcpy(pszString, s.c_str()); }
/** * Writes the auto message */ void write_automessage() { std::vector<std::string> lines; std::string rollOver; GetSession()->bout << "\r\n|#9Enter auto-message. Max 5 lines. Colors allowed:|#0\r\n\n"; for (int i = 0; i < 5; i++) { GetSession()->bout << "|#7" << i + 1 << ":|#0"; std::string line; inli(line, rollOver, 70); StringTrimEnd(line); lines.push_back(line); } GetSession()->bout.NewLine(); bool bAnonStatus = false; if (getslrec(GetSession()->GetEffectiveSl()).ability & ability_post_anony) { GetSession()->bout << "|#9Anonymous? "; bAnonStatus = yesno(); } GetSession()->bout << "|#9Is this OK? "; if (yesno()) { WStatus *pStatus = GetApplication()->GetStatusManager()->BeginTransaction(); pStatus->SetAutoMessageAnonymous(bAnonStatus); pStatus->SetAutoMessageAuthorUserNumber(GetSession()->usernum); GetApplication()->GetStatusManager()->CommitTransaction(pStatus); WTextFile file(syscfg.gfilesdir, AUTO_MSG, "wt"); std::string authorName = GetSession()->GetCurrentUser()->GetUserNameAndNumber(GetSession()->usernum); file.WriteFormatted("%s\r\n", authorName.c_str()); sysoplog("Changed Auto-message"); #if defined(_MSC_VER) && (_MSC_VER < 1800) for (std::vector<std::string>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter) { std::string line = (*iter); StringTrimEnd(line); #else for (const auto& line : lines) { #endif file.Write(line); file.Write("\r\n"); sysoplog(line, true); } GetSession()->bout << "\r\n|#5Auto-message saved.\r\n\n"; file.Close(); } } char ShowAMsgMenuAndGetInput(const std::string& autoMessageLockFileName) { bool bCanWrite = false; if (!GetSession()->GetCurrentUser()->IsRestrictionAutomessage() && !WFile::Exists(autoMessageLockFileName)) { bCanWrite = (getslrec(GetSession()->GetEffectiveSl()).posts) ? true : false; } char cmdKey = 0; if (cs()) { GetSession()->bout << "|#9(|#2Q|#9)uit, (|#2R|#9)ead, (|#2A|#9)uto-reply, (|#2W|#9)rite, (|#2L|#9)ock, (|#2D|#9)el, (|#2U|#9)nlock : "; cmdKey = onek("QRWALDU", true); } else if (bCanWrite) { GetSession()->bout << "|#9(|#2Q|#9)uit, (|#2R|#9)ead, (|#2A|#9)uto-reply, (|#2W|#9)rite : "; cmdKey = onek("QRWA", true); } else { GetSession()->bout << "|#9(|#2Q|#9)uit, (|#2R|#9)ead, (|#2A|#9)uto-reply : "; cmdKey = onek("QRA", true); } return cmdKey; }