/[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.4 by sysadm, Fri Oct 22 19:51:01 2004 UTC Revision 1.5 by sysadm, Sat Oct 23 18:41:41 2004 UTC
# Line 53  bbs_login () Line 53  bbs_login ()
53        count++;        count++;
54    
55        if (strcmp (username, "guest") == 0)        if (strcmp (username, "guest") == 0)
56          return 1;          {
57              load_guest_info ();
58              return 0;
59            }
60    
61          if (strcmp (username, "new") == 0)
62            {
63              if (user_register () == 0)
64                return 0;
65              else
66               return -2;
67            }
68    
69        if (strlen (username) > 0)        if (strlen (username) > 0)
70          {          {
# Line 63  bbs_login () Line 74  bbs_login ()
74    
75            str_input (password, 19, 1);            str_input (password, 19, 1);
76    
77            ok = (check_user (username, password) == 0);            ok = (check_user (username, password) == 0);
78          }          }
79        if (count >= 3 && !ok)        if (count >= 3 && !ok)
80          {          {
# Line 134  check_user (char *username, char *passwo Line 145  check_user (char *username, char *passwo
145        sprintf (sql,        sprintf (sql,
146                 "insert delayed into user_err_login_log"                 "insert delayed into user_err_login_log"
147                 "(username,password,login_dt,login_ip) values"                 "(username,password,login_dt,login_ip) values"
148                 "('%s','%s',now(),'%s')",                 "('%s','%s',now(),'%s')", username, password, hostaddr_client);
                username, password, hostaddr_client);  
149        if (mysql_query (db, sql) != 0)        if (mysql_query (db, sql) != 0)
150          {          {
151            log_error ("Insert into user_err_login_log failed\n");            log_error ("Insert into user_err_login_log failed\n");
# Line 150  check_user (char *username, char *passwo Line 160  check_user (char *username, char *passwo
160      }      }
161    mysql_free_result (rs);    mysql_free_result (rs);
162    
163    BBS_passwd_complex = verify_pass_complexity(password, username, 6);    BBS_passwd_complex = verify_pass_complexity (password, username, 6);
164    
165    ret = load_user_info (db, BBS_uid);    ret = load_user_info (db, BBS_uid);
166    
   mysql_close (db);  
   
167    switch (ret)    switch (ret)
168      {      {
169      case 0:                     //Login successfully      case 0:                     //Login successfully
# Line 169  check_user (char *username, char *passwo Line 177  check_user (char *username, char *passwo
177      case -2:                    //Unused      case -2:                    //Unused
178        return 0;        return 0;
179        break;        break;
180      case -3:      case -3:                    //Dead
181        prints ("\033[1;31m很遗憾,您已经永远离开了我们的世界!\033[m\r\n");        prints ("\033[1;31m很遗憾,您已经永远离开了我们的世界!\033[m\r\n");
182        iflush ();        iflush ();
183        return 1;        return 1;
# Line 177  check_user (char *username, char *passwo Line 185  check_user (char *username, char *passwo
185        return -2;        return -2;
186      }      }
187    
188      mysql_close (db);
189    
190    return 0;    return 0;
191  }  }
192    
# Line 240  load_user_info (MYSQL * db, long int BBS Line 250  load_user_info (MYSQL * db, long int BBS
250    mysql_free_result (rs);    mysql_free_result (rs);
251    
252    sprintf (sql,    sprintf (sql,
253     "insert delayed into user_login_log"             "insert delayed into user_login_log"
254     "(uid,login_dt,login_ip) values(%ld"             "(uid,login_dt,login_ip) values(%ld"
255     ",now(),'%s')",             ",now(),'%s')", BBS_uid, hostaddr_client);
    BBS_uid, hostaddr_client);  
256    if (mysql_query (db, sql) != 0)    if (mysql_query (db, sql) != 0)
257      {      {
258        log_error ("Insert into user_login_log failed\n");        log_error ("Insert into user_login_log failed\n");
# Line 251  load_user_info (MYSQL * db, long int BBS Line 260  load_user_info (MYSQL * db, long int BBS
260      }      }
261    
262    load_priv (db, &BBS_priv, BBS_uid, BBS_auth_uid,    load_priv (db, &BBS_priv, BBS_uid, BBS_auth_uid,
263      (!BBS_passwd_complex ? S_MAN_M : S_NONE) |               (!BBS_passwd_complex ? S_MAN_M : S_NONE) |
264      (BBS_auth_uid ? S_NONE : S_MAIL));               (BBS_auth_uid ? S_NONE : S_MAIL));
265    
266    BBS_last_access_tm = BBS_login_tm = time (0);    BBS_last_access_tm = BBS_login_tm = time (0);
267    BBS_last_sub_tm = time (0) - 60;    BBS_last_sub_tm = time (0) - 60;
268    
269    sprintf (sql,    sprintf (sql,
270     "update user_pubinfo set visit_count=visit_count+1,"             "update user_pubinfo set visit_count=visit_count+1,"
271     "last_login_dt=now() where uid=%ld", BBS_uid);             "last_login_dt=now() where uid=%ld", BBS_uid);
272    if (mysql_query (db, sql) != 0)    if (mysql_query (db, sql) != 0)
273      {      {
274        log_error ("Update user_pubinfo failed\n");        log_error ("Update user_pubinfo failed\n");
# Line 268  load_user_info (MYSQL * db, long int BBS Line 277  load_user_info (MYSQL * db, long int BBS
277    
278    return 0;    return 0;
279  }  }
280    
281    int
282    load_guest_info (MYSQL * db, long int BBS_uid)
283    {
284      MYSQL_RES *rs;
285      MYSQL_ROW row;
286    
287      db = (MYSQL *) db_open ();
288      if (db == NULL)
289        {
290          return -1;
291        }
292    
293      load_priv (db, &BBS_priv, 0, 0, S_NONE);
294    
295      BBS_last_access_tm = BBS_login_tm = time (0);
296      BBS_last_sub_tm = time (0) - 60;
297    
298      mysql_close (db);
299    
300      return 0;
301    }


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

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