/[LeafOK_CVS]/lbbs/src/login.c
ViewVC logotype

Diff of /lbbs/src/login.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.59 by sysadm, Thu Oct 16 10:10:48 2025 UTC Revision 1.63 by sysadm, Mon Nov 3 06:21:01 2025 UTC
# Line 114  int check_user(const char *username, con Line 114  int check_user(const char *username, con
114          // Verify format          // Verify format
115          for (i = 0; ok && username[i] != '\0'; i++)          for (i = 0; ok && username[i] != '\0'; i++)
116          {          {
117                  if (!(isalpha(username[i]) || (i > 0 && isdigit(username[i]))))                  if (!(isalpha(username[i]) || (i > 0 && (isdigit(username[i]) || username[i] == '_'))))
118                  {                  {
119                          ok = 0;                          ok = 0;
120                  }                  }
121          }          }
122          if (ok && (i < 3 || i > 12))          if (ok && (i < 5 || i > BBS_username_max_len))
123          {          {
124                  ok = 0;                  ok = 0;
125          }          }
# Line 130  int check_user(const char *username, con Line 130  int check_user(const char *username, con
130                          ok = 0;                          ok = 0;
131                  }                  }
132          }          }
133          if (ok && (i < 5 || i > 12))          if (ok && (i < 5 || i > BBS_password_max_len))
134          {          {
135                  ok = 0;                  ok = 0;
136          }          }
# Line 488  int user_online_add(MYSQL *db) Line 488  int user_online_add(MYSQL *db)
488  {  {
489          char sql[SQL_BUFFER_LEN];          char sql[SQL_BUFFER_LEN];
490    
491          if (user_online_del(db) != 0)          snprintf(sql, sizeof(sql),
492                             "INSERT INTO visit_log(dt, IP) VALUES(NOW(), '%s')",
493                             hostaddr_client);
494            if (mysql_query(db, sql) != 0)
495          {          {
496                    log_error("Add visit log error: %s\n", mysql_error(db));
497                  return -1;                  return -1;
498          }          }
499    
500            if (user_online_del(db) != 0)
501            {
502                    return -2;
503            }
504    
505          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
506                           "INSERT INTO user_online(SID, UID, ip, login_tm, last_tm) "                           "INSERT INTO user_online(SID, UID, ip, current_action, login_tm, last_tm) "
507                           "VALUES('Telnet_Process_%d', %d, '%s', NOW(), NOW())",                           "VALUES('Telnet_Process_%d', %d, '%s', 'LOGIN', NOW(), NOW())",
508                           getpid(), BBS_priv.uid, hostaddr_client);                           getpid(), BBS_priv.uid, hostaddr_client);
509          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)
510          {          {
511                  log_error("Add user_online error: %s\n", mysql_error(db));                  log_error("Add user_online error: %s\n", mysql_error(db));
512                  return -1;                  return -3;
513          }          }
514    
515          return 0;          return 0;
# Line 529  int user_online_exp(MYSQL *db) Line 538  int user_online_exp(MYSQL *db)
538          // +1 exp for every 5 minutes online since last logout          // +1 exp for every 5 minutes online since last logout
539          // but at most 24 hours worth of exp can be gained in Telnet session          // but at most 24 hours worth of exp can be gained in Telnet session
540          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
541                          "UPDATE user_pubinfo SET exp = exp + FLOOR(LEAST(TIMESTAMPDIFF("                           "UPDATE user_pubinfo SET exp = exp + FLOOR(LEAST(TIMESTAMPDIFF("
542                          "SECOND, GREATEST(last_login_dt, IF(last_logout_dt IS NULL, last_login_dt, last_logout_dt)), NOW()"                           "SECOND, GREATEST(last_login_dt, IF(last_logout_dt IS NULL, last_login_dt, last_logout_dt)), NOW()"
543                          ") / 60 / 5, 12 * 24)), last_logout_dt = NOW() "                           ") / 60 / 5, 12 * 24)), last_logout_dt = NOW() "
544                          "WHERE UID = %d",                           "WHERE UID = %d",
545                          BBS_priv.uid);                           BBS_priv.uid);
546          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)
547          {          {
548                  log_error("Update user_pubinfo error: %s\n", mysql_error(db));                  log_error("Update user_pubinfo error: %s\n", mysql_error(db));
# Line 570  int user_online_update(const char *actio Line 579  int user_online_update(const char *actio
579          }          }
580    
581          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
582                           "UPDATE user_online SET current_action = '%s', last_tm=NOW() "                           "UPDATE user_online SET current_action = '%s', last_tm = NOW() "
583                           "WHERE SID = 'Telnet_Process_%d'",                           "WHERE SID = 'Telnet_Process_%d'",
584                           BBS_current_action, getpid());                           BBS_current_action, getpid());
585          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1