| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 16 |
|
|
| 17 |
|
#define _POSIX_C_SOURCE 200112L |
| 18 |
|
|
| 19 |
#include "login.h" |
#include "login.h" |
| 20 |
#include "bbs.h" |
#include "bbs.h" |
| 21 |
#include "user_priv.h" |
#include "user_priv.h" |
| 24 |
#include "io.h" |
#include "io.h" |
| 25 |
#include "screen.h" |
#include "screen.h" |
| 26 |
#include "database.h" |
#include "database.h" |
| 27 |
|
#include <errno.h> |
| 28 |
#include <ctype.h> |
#include <ctype.h> |
| 29 |
#include <string.h> |
#include <string.h> |
| 30 |
#include <mysql.h> |
#include <mysql.h> |
| 101 |
char client_addr[IP_ADDR_LEN]; |
char client_addr[IP_ADDR_LEN]; |
| 102 |
int i; |
int i; |
| 103 |
int ok = 1; |
int ok = 1; |
| 104 |
|
char user_tz_env[BBS_user_tz_max_len + 2]; |
| 105 |
|
|
| 106 |
// Verify format |
// Verify format |
| 107 |
for (i = 0; ok && username[i] != '\0'; i++) |
for (i = 0; ok && username[i] != '\0'; i++) |
| 323 |
|
|
| 324 |
BBS_last_access_tm = BBS_login_tm = time(0); |
BBS_last_access_tm = BBS_login_tm = time(0); |
| 325 |
|
|
| 326 |
|
// Set user tz to process env |
| 327 |
|
if (BBS_user_tz[0] != '\0') |
| 328 |
|
{ |
| 329 |
|
user_tz_env[0] = ':'; |
| 330 |
|
strncpy(user_tz_env + 1, BBS_user_tz, sizeof(user_tz_env) - 2); |
| 331 |
|
user_tz_env[sizeof(user_tz_env) - 1] = '\0'; |
| 332 |
|
|
| 333 |
|
if (setenv("TZ", user_tz_env, 1) == -1) |
| 334 |
|
{ |
| 335 |
|
log_error("setenv(TZ = %s) error %d\n", user_tz_env, errno); |
| 336 |
|
return -3; |
| 337 |
|
} |
| 338 |
|
|
| 339 |
|
tzset(); |
| 340 |
|
} |
| 341 |
|
|
| 342 |
return 0; |
return 0; |
| 343 |
} |
} |
| 344 |
|
|
| 351 |
time_t last_login_dt; |
time_t last_login_dt; |
| 352 |
|
|
| 353 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 354 |
"SELECT life, UNIX_TIMESTAMP(last_login_dt) " |
"SELECT life, UNIX_TIMESTAMP(last_login_dt), user_timezone " |
| 355 |
"FROM user_pubinfo WHERE UID = %ld", |
"FROM user_pubinfo WHERE UID = %ld", |
| 356 |
BBS_uid); |
BBS_uid); |
| 357 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 368 |
{ |
{ |
| 369 |
life = atoi(row[0]); |
life = atoi(row[0]); |
| 370 |
last_login_dt = (time_t)atol(row[1]); |
last_login_dt = (time_t)atol(row[1]); |
| 371 |
|
|
| 372 |
|
strncpy(BBS_user_tz, row[2], sizeof(BBS_user_tz) - 1); |
| 373 |
|
BBS_user_tz[sizeof(BBS_user_tz) - 1] = '\0'; |
| 374 |
} |
} |
| 375 |
else |
else |
| 376 |
{ |
{ |