From 76cb37333f5bb52ff9d2d58973fa5d02cbe8471a Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Windows 11)" <rob@synchro.net> Date: Sun, 10 Mar 2024 14:47:41 -0700 Subject: [PATCH] More details from text.dat strings when removing files or credits Don't display "FREE" in file listings for 0 byte files. When removefcdt() is called for an unknown file uploader, use the new UnknownUploader text.dat string to display the username and filename. When prompting to remove credits, include the username from which to remove the credits. These usability improvements came from watching Deuce struggle to remove malicious uploaded-files and credits from (presumably Guest) user. I should watch sysops manage their BBSes more often. --- src/sbbs3/file.cpp | 10 +++++----- src/sbbs3/text.h | 2 ++ src/sbbs3/text_defaults.c | 8 ++++++-- src/sbbs3/text_id.c | 2 ++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/sbbs3/file.cpp b/src/sbbs3/file.cpp index 449a7ebc22..0d12073a64 100644 --- a/src/sbbs3/file.cpp +++ b/src/sbbs3/file.cpp @@ -43,7 +43,7 @@ void sbbs_t::showfileinfo(file_t* f, bool show_extdesc) , byte_estimate_to_str(f->size, tmp2, sizeof(tmp2), /* units: */1024, /* precision: */1)); bprintf(P_TRUNCATE, text[FiCredits] - ,(cfg.dir[f->dir]->misc&DIR_FREE || !f->cost) ? "FREE" : u64toac(f->cost,tmp)); + ,(cfg.dir[f->dir]->misc&DIR_FREE || (f->size > 0 && f->cost <= 0)) ? text[FREE] : u64toac(f->cost,tmp)); if(getfilesize(&cfg, f) > 0 && (uint64_t)f->size == smb_getfilesize(&f->idx)) { #if 0 // I don't think anyone cares about the CRC-16 checksum value of a file if(f->file_idx.hash.flags & SMB_HASH_CRC16) { @@ -166,7 +166,7 @@ bool sbbs_t::removefcdt(file_t* f) long cdt; if((u=matchuser(&cfg,f->from,TRUE /*sysop_alias*/))==0) { - bputs(text[UnknownUser]); + bprintf(text[UnknownUploader], f->from, f->name); return(false); } cdt=0L; @@ -192,15 +192,15 @@ bool sbbs_t::removefcdt(file_t* f) *f->cost*(cfg.dir[f->dir]->dn_pct/100.0)); if(dir_op(f->dir)) { ultoa(cdt, str, 10); - bputs(text[CreditsToRemove]); + bprintf(text[CreditsToRemove], f->from); getstr(str, 10, K_NUMBER|K_LINE|K_EDIT|K_AUTODEL); if(msgabort(true)) return false; - cdt = atol(str); + cdt = atol(str); } adjustuserval(&cfg, u, USER_CDT, -cdt); sprintf(tmp,text[FileRemovedUserMsg] - ,f->name,cdt ? ultoac(cdt,str) : text[No]); + ,f->name,cdt > 0 ? ultoac(cdt,str) : text[No]); putsmsg(u,tmp); } diff --git a/src/sbbs3/text.h b/src/sbbs3/text.h index 158f27b601..c6cda34b88 100644 --- a/src/sbbs3/text.h +++ b/src/sbbs3/text.h @@ -892,6 +892,8 @@ enum text { ,PasswordChar ,NodeConnectionSFTP ,QWKSettingsWrapText + ,UnknownUploader + ,FREE ,TOTAL_TEXT }; diff --git a/src/sbbs3/text_defaults.c b/src/sbbs3/text_defaults.c index 8a2c7c219b..66f05a668f 100644 --- a/src/sbbs3/text_defaults.c +++ b/src/sbbs3/text_defaults.c @@ -411,7 +411,8 @@ const char * const text_defaults[TOTAL_TEXT]={ ,"\x41\x64\x64\x20\x25\x73\x20\x74\x6f\x20\x25\x73\x20\x25\x73" // 246 AddToOfflineDirQ ,"\x52\x65\x6d\x6f\x76\x65\x20\x63\x72\x65\x64\x69\x74\x73" // 247 RemoveCreditsQ ,"\x0d\x0a\x55\x73\x65\x72\x20\x6e\x6f\x74\x20\x61\x76\x61\x69\x6c\x61\x62\x6c\x65\x2e\x0d\x0a" // 248 UserNotFound - ,"\x01\x5f\x01\x79\x01\x68\x43\x72\x65\x64\x69\x74\x73\x20\x74\x6f\x20\x72\x65\x6d\x6f\x76\x65\x3a\x20\x01\x6e" // 249 CreditsToRemove + ,"\x01\x5f\x01\x79\x01\x68\x43\x72\x65\x64\x69\x74\x73\x20\x74\x6f\x20\x72\x65\x6d\x6f\x76\x65\x20\x66\x72\x6f\x6d\x20\x75\x70\x6c" + "\x6f\x61\x64\x65\x72\x20\x28\x25\x73\x29\x3a\x20\x01\x6e" // 249 CreditsToRemove ,"\x01\x5f\x01\x77\x01\x68\x25\x73\x20\x77\x61\x73\x20\x72\x65\x6d\x6f\x76\x65\x64\x2e\x0d\x0a\x01\x6e\x01\x67\x59\x6f\x75\x20\x6c" "\x6f\x73\x74\x20\x25\x73\x20\x63\x72\x65\x64\x69\x74\x73\x2e\x0d\x0a" // 250 FileRemovedUserMsg ,"\x01\x5f\x01\x3f\x01\x79\x01\x68\x46\x69\x6c\x65\x6e\x61\x6d\x65\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3a\x20\x01\x6e" // 251 EditFilename @@ -1328,7 +1329,7 @@ const char * const text_defaults[TOTAL_TEXT]={ "" // 797 MIMEDecodedPlainTextFmt ,"\x01\x2f\x40\x45\x58\x45\x43\x3a\x53\x48\x4f\x57\x4d\x53\x47\x41\x56\x41\x54\x41\x52\x40\x0d\x0a" // 798 MsgHdrBodySeparator ,"\x01\x2f\x0d\x0a\x40\x45\x58\x45\x43\x3a\x53\x48\x4f\x57\x46\x49\x4c\x45\x41\x56\x41\x54\x41\x52\x40" // 799 FileHdrDescSeparator - ,"\x52\x65\x6d\x6f\x76\x65\x20\x66\x69\x6c\x65" // 800 RemoveFileQ + ,"\x52\x65\x6d\x6f\x76\x65\x20\x66\x69\x6c\x65\x20\x66\x72\x6f\x6d\x20\x64\x61\x74\x61\x62\x61\x73\x65" // 800 RemoveFileQ ,"\x4f\x72\x69\x67\x69\x6e\x61\x74\x69\x6e\x67\x20\x41\x64\x64\x72\x65\x73\x73" // 801 OriginFidoAddr ,"\x01\x6e\x01\x68\xfb\x20\x01\x6d\x25\x2e\x37\x37\x73\x0d\x0a" // 802 VoteNoticeFmt ,"\x0d\x0a\x54\x61\x67\x20\x74\x68\x69\x73\x20\x6d\x65\x73\x73\x61\x67\x65" // 803 TagMessageQ @@ -1432,4 +1433,7 @@ const char * const text_defaults[TOTAL_TEXT]={ ,"\x20\x76\x69\x61\x20\x73\x66\x74\x70" // 874 NodeConnectionSFTP ,"\x01\x6e\x01\x62\x5b\x01\x68\x01\x77\x57\x01\x6e\x01\x62\x5d\x20\x01\x68\x57\x6f\x72\x64\x2d\x77\x72\x61\x70\x20\x4d\x65\x73\x73" "\x61\x67\x65\x20\x54\x65\x78\x74\x20\x20\x20\x20\x20\x20\x20\x01\x6e\x01\x62\x3a\x20\x01\x63\x25\x73\x0d\x0a" // 875 QWKSettingsWrapText + ,"\x01\x2f\x55\x6e\x6b\x6e\x6f\x77\x6e\x20\x75\x70\x6c\x6f\x61\x64\x65\x72\x20\x28\x25\x73\x29\x20\x6f\x66\x20\x66\x69\x6c\x65\x3a" + "\x20\x25\x73" // 877 UnknownUploader + ,"\x46\x52\x45\x45" // 878 FREE }; diff --git a/src/sbbs3/text_id.c b/src/sbbs3/text_id.c index b4b391fb6d..ecff0bd961 100644 --- a/src/sbbs3/text_id.c +++ b/src/sbbs3/text_id.c @@ -876,4 +876,6 @@ const char* const text_id[]={ ,"PasswordChar" ,"NodeConnectionSFTP" ,"QWKSettingsWrapText" + ,"UnknownUploader" + ,"FREE" }; -- GitLab