| 18 |
#include "bbs.h" |
#include "bbs.h" |
| 19 |
#include "common.h" |
#include "common.h" |
| 20 |
#include "io.h" |
#include "io.h" |
| 21 |
|
#include "database.h" |
| 22 |
#include <mysql.h> |
#include <mysql.h> |
| 23 |
#include <regex.h> |
#include <regex.h> |
| 24 |
|
|
| 64 |
if (user_register () == 0) |
if (user_register () == 0) |
| 65 |
return 0; |
return 0; |
| 66 |
else |
else |
| 67 |
return -2; |
return -2; |
| 68 |
} |
} |
| 69 |
|
|
| 70 |
if (strlen (username) > 0) |
if (strlen (username) > 0) |
| 113 |
} |
} |
| 114 |
|
|
| 115 |
sprintf (sql, |
sprintf (sql, |
| 116 |
"select UID,p_login from user_list where username='%s' " |
"select UID,username,p_login from user_list where username='%s' " |
| 117 |
"and (password=MD5('%s') or password=PASSWORD('%s')) and " |
"and (password=MD5('%s') or password=PASSWORD('%s')) and " |
| 118 |
"enable", username, password, password); |
"enable", username, password, password); |
| 119 |
if (mysql_query (db, sql) != 0) |
if (mysql_query (db, sql) != 0) |
| 129 |
if (row = mysql_fetch_row (rs)) |
if (row = mysql_fetch_row (rs)) |
| 130 |
{ |
{ |
| 131 |
BBS_uid = atol (row[0]); |
BBS_uid = atol (row[0]); |
| 132 |
if (atoi (row[1]) == 0) |
strcpy (BBS_username, row[1]); |
| 133 |
|
if (atoi (row[2]) == 0) |
| 134 |
{ |
{ |
| 135 |
mysql_free_result (rs); |
mysql_free_result (rs); |
| 136 |
mysql_close (db); |
mysql_close (db); |
| 249 |
{ |
{ |
| 250 |
BBS_auth_uid = atol (row[0]); |
BBS_auth_uid = atol (row[0]); |
| 251 |
} |
} |
| 252 |
|
else |
| 253 |
|
{ |
| 254 |
|
BBS_auth_uid = 0; |
| 255 |
|
} |
| 256 |
mysql_free_result (rs); |
mysql_free_result (rs); |
| 257 |
|
|
| 258 |
sprintf (sql, |
sprintf (sql, |
| 296 |
return -1; |
return -1; |
| 297 |
} |
} |
| 298 |
|
|
| 299 |
|
strcpy (BBS_username, "guest"); |
| 300 |
|
|
| 301 |
load_priv (db, &BBS_priv, 0, 0, S_NONE); |
load_priv (db, &BBS_priv, 0, 0, S_NONE); |
| 302 |
|
|
| 303 |
BBS_last_access_tm = BBS_login_tm = time (0); |
BBS_last_access_tm = BBS_login_tm = time (0); |