| 6 |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
|
#ifdef HAVE_CONFIG_H |
| 10 |
|
#include "config.h" |
| 11 |
|
#endif |
| 12 |
|
|
| 13 |
#include "common.h" |
#include "common.h" |
| 14 |
#include "io.h" |
#include "io.h" |
| 15 |
#include "log.h" |
#include "log.h" |
| 218 |
if (ch != KEY_NULL && ch != KEY_TIMEOUT) |
if (ch != KEY_NULL && ch != KEY_TIMEOUT) |
| 219 |
{ |
{ |
| 220 |
BBS_last_access_tm = time(NULL); |
BBS_last_access_tm = time(NULL); |
| 221 |
|
|
| 222 |
|
// Refresh current action |
| 223 |
|
if (user_online_update(NULL) < 0) |
| 224 |
|
{ |
| 225 |
|
log_error("user_online_update(NULL) error\n"); |
| 226 |
|
} |
| 227 |
} |
} |
| 228 |
|
|
| 229 |
switch (ch) |
switch (ch) |
| 230 |
{ |
{ |
| 231 |
case KEY_NULL: // broken pipe |
case KEY_NULL: // broken pipe |
| 232 |
|
#ifdef _DEBUG |
| 233 |
log_error("KEY_NULL\n"); |
log_error("KEY_NULL\n"); |
| 234 |
|
#endif |
| 235 |
case KEY_ESC: |
case KEY_ESC: |
| 236 |
case KEY_LEFT: |
case KEY_LEFT: |
| 237 |
return EXIT_LIST; // exit list |
return EXIT_LIST; // exit list |
| 238 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 239 |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time) |
| 240 |
{ |
{ |
| 241 |
log_error("User input timeout\n"); |
log_error("User input timeout\n"); |
| 242 |
return EXIT_LIST; // exit list |
return EXIT_LIST; // exit list |
| 508 |
// Verify format |
// Verify format |
| 509 |
for (i = 0, ok = 1; ok && username[i] != '\0'; i++) |
for (i = 0, ok = 1; ok && username[i] != '\0'; i++) |
| 510 |
{ |
{ |
| 511 |
if (!(isalpha(username[i]) || (i > 0 && (isdigit(username[i]) || username[i] == '_')))) |
if (!(isalpha((int)username[i]) || (i > 0 && (isdigit((int)username[i]) || username[i] == '_')))) |
| 512 |
{ |
{ |
| 513 |
ok = 0; |
ok = 0; |
| 514 |
} |
} |
| 551 |
prints("存在多个匹配的用户,按\033[1;33mEnter\033[m精确查找"); |
prints("存在多个匹配的用户,按\033[1;33mEnter\033[m精确查找"); |
| 552 |
iflush(); |
iflush(); |
| 553 |
|
|
| 554 |
ch = igetch_t(MAX_DELAY_TIME); |
ch = igetch_t(BBS_max_user_idle_time); |
| 555 |
switch (ch) |
switch (ch) |
| 556 |
{ |
{ |
| 557 |
case KEY_NULL: |
case KEY_NULL: |
| 564 |
break; |
break; |
| 565 |
default: |
default: |
| 566 |
i = (int)strnlen(username, sizeof(username) - 1); |
i = (int)strnlen(username, sizeof(username) - 1); |
| 567 |
if (i + 1 <= BBS_username_max_len && (isalnum((char)ch) || ch == '_')) |
if (i + 1 <= BBS_username_max_len && (isalnum(ch) || ch == '_')) |
| 568 |
{ |
{ |
| 569 |
username[i] = (char)ch; |
username[i] = (char)ch; |
| 570 |
username[i + 1] = '\0'; |
username[i + 1] = '\0'; |