| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 16 |
|
|
| 17 |
|
#define _POSIX_C_SOURCE 200112L |
| 18 |
|
|
| 19 |
#include "login.h" |
#include "login.h" |
|
#include "register.h" |
|
| 20 |
#include "bbs.h" |
#include "bbs.h" |
| 21 |
#include "user_priv.h" |
#include "user_priv.h" |
|
#include "reg_ex.h" |
|
| 22 |
#include "common.h" |
#include "common.h" |
| 23 |
#include "log.h" |
#include "log.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> |
| 29 |
#include <string.h> |
#include <string.h> |
|
#include <mysql.h> |
|
| 30 |
#include <regex.h> |
#include <regex.h> |
| 31 |
|
#include <stdlib.h> |
| 32 |
#include <unistd.h> |
#include <unistd.h> |
| 33 |
|
#include <mysql/mysql.h> |
| 34 |
|
|
| 35 |
void login_fail() |
int bbs_login(void) |
|
{ |
|
|
display_file(DATA_LOGIN_ERROR); |
|
|
|
|
|
sleep(1); |
|
|
} |
|
|
|
|
|
int bbs_login() |
|
| 36 |
{ |
{ |
| 37 |
char username[BBS_username_max_len + 1]; |
char username[BBS_username_max_len + 1]; |
| 38 |
char password[BBS_password_max_len + 1]; |
char password[BBS_password_max_len + 1]; |
| 39 |
int count = 0; |
int i = 0; |
| 40 |
int ok = 0; |
int ok = 0; |
| 41 |
|
|
| 42 |
// Input username |
for (; !SYS_server_exit && !ok && i < BBS_login_retry_times; i++) |
|
while (!ok) |
|
| 43 |
{ |
{ |
| 44 |
prints("\033[1;33m请输入帐号\033[m(试用请输入`\033[1;36mguest\033[m', " |
prints("\033[1;33m请输入帐号\033[m(试用请输入`\033[1;36mguest\033[m', " |
| 45 |
"注册请输入`\033[1;31mnew\033[m'): "); |
"注册请输入`\033[1;31mnew\033[m'): "); |
| 46 |
iflush(); |
iflush(); |
| 47 |
|
|
| 48 |
str_input(username, sizeof(username), DOECHO); |
if (str_input(username, sizeof(username), DOECHO) < 0) |
| 49 |
count++; |
{ |
| 50 |
|
continue; |
| 51 |
|
} |
| 52 |
|
|
| 53 |
if (strcmp(username, "guest") == 0) |
if (strcmp(username, "guest") == 0) |
| 54 |
{ |
{ |
| 55 |
MYSQL *db = db_open(); |
load_guest_info(); |
|
if (db == NULL) |
|
|
{ |
|
|
return -1; |
|
|
} |
|
|
|
|
|
load_guest_info(db); |
|
|
|
|
|
mysql_close(db); |
|
| 56 |
|
|
| 57 |
return 0; |
return 0; |
| 58 |
} |
} |
| 59 |
|
|
| 60 |
if (strcmp(username, "new") == 0) |
if (strcmp(username, "new") == 0) |
| 61 |
{ |
{ |
| 62 |
if (user_register() == 0) |
display_file(DATA_REGISTER, 1, 1); |
| 63 |
{ |
|
| 64 |
return 0; |
return 0; |
|
} |
|
|
else |
|
|
{ |
|
|
return -2; |
|
|
} |
|
| 65 |
} |
} |
| 66 |
|
|
| 67 |
if (username[0] != '\0') |
if (username[0] != '\0') |
| 68 |
{ |
{ |
|
// Input password |
|
| 69 |
prints("\033[1;37m请输入密码\033[m: "); |
prints("\033[1;37m请输入密码\033[m: "); |
| 70 |
iflush(); |
iflush(); |
| 71 |
|
|
| 72 |
str_input(password, sizeof(password), NOECHO); |
if (str_input(password, sizeof(password), NOECHO) < 0) |
|
|
|
|
MYSQL *db = db_open(); |
|
|
if (db == NULL) |
|
| 73 |
{ |
{ |
| 74 |
return -1; |
continue; |
| 75 |
} |
} |
| 76 |
|
|
| 77 |
ok = (check_user(db, username, password) == 0); |
ok = (check_user(username, password) == 0); |
| 78 |
|
iflush(); |
|
mysql_close(db); |
|
|
} |
|
|
if (count >= 3 && !ok) |
|
|
{ |
|
|
login_fail(); |
|
|
return -1; |
|
| 79 |
} |
} |
| 80 |
} |
} |
| 81 |
|
|
| 82 |
|
if (!ok) |
| 83 |
|
{ |
| 84 |
|
display_file(DATA_LOGIN_ERROR, 1, 1); |
| 85 |
|
return -1; |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
log_common("User \"%s\"(%ld) login from %s:%d\n", |
| 89 |
|
BBS_username, BBS_priv.uid, hostaddr_client, port_client); |
| 90 |
|
|
| 91 |
return 0; |
return 0; |
| 92 |
} |
} |
| 93 |
|
|
| 94 |
int check_user(MYSQL *db, char *username, char *password) |
int check_user(const char *username, const char *password) |
| 95 |
{ |
{ |
| 96 |
|
MYSQL *db; |
| 97 |
MYSQL_RES *rs; |
MYSQL_RES *rs; |
| 98 |
MYSQL_ROW row; |
MYSQL_ROW row; |
| 99 |
char sql[SQL_BUFFER_LEN]; |
char sql[SQL_BUFFER_LEN]; |
| 100 |
int ret; |
int ret; |
| 101 |
long BBS_uid = 0; |
int BBS_uid = 0; |
| 102 |
char client_addr[IP_ADDR_LEN]; |
char client_addr[IP_ADDR_LEN]; |
| 103 |
|
int i; |
| 104 |
|
int ok = 1; |
| 105 |
|
char user_tz_env[BBS_user_tz_max_len + 2]; |
| 106 |
|
|
| 107 |
|
db = db_open(); |
| 108 |
|
if (db == NULL) |
| 109 |
|
{ |
| 110 |
|
return -1; |
| 111 |
|
} |
| 112 |
|
|
| 113 |
// Verify format |
// Verify format |
| 114 |
if (ireg("^[A-Za-z][A-Za-z0-9]{2,11}$", username, 0, NULL) != 0 || |
for (i = 0; ok && username[i] != '\0'; i++) |
| 115 |
ireg("^[A-Za-z0-9]{5,12}$", password, 0, NULL) != 0) |
{ |
| 116 |
|
if (!(isalpha(username[i]) || (i > 0 && isdigit(username[i])))) |
| 117 |
|
{ |
| 118 |
|
ok = 0; |
| 119 |
|
} |
| 120 |
|
} |
| 121 |
|
if (ok && (i < 3 || i > 12)) |
| 122 |
|
{ |
| 123 |
|
ok = 0; |
| 124 |
|
} |
| 125 |
|
for (i = 0; ok && password[i] != '\0'; i++) |
| 126 |
|
{ |
| 127 |
|
if (!isalnum(password[i])) |
| 128 |
|
{ |
| 129 |
|
ok = 0; |
| 130 |
|
} |
| 131 |
|
} |
| 132 |
|
if (ok && (i < 5 || i > 12)) |
| 133 |
|
{ |
| 134 |
|
ok = 0; |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
if (!ok) |
| 138 |
{ |
{ |
| 139 |
prints("\033[1;31m用户名或密码格式错误...\033[m\r\n"); |
prints("\033[1;31m用户名或密码格式错误...\033[m\r\n"); |
|
iflush(); |
|
| 140 |
return 1; |
return 1; |
| 141 |
} |
} |
| 142 |
|
|
| 143 |
// Begin transaction |
// Begin transaction |
| 144 |
if (mysql_query(db, "SET autocommit=0") != 0) |
if (mysql_query(db, "SET autocommit=0") != 0) |
| 145 |
{ |
{ |
| 146 |
log_error("SET autocommit=0 failed\n"); |
log_error("SET autocommit=0 error: %s\n", mysql_error(db)); |
| 147 |
|
mysql_close(db); |
| 148 |
return -1; |
return -1; |
| 149 |
} |
} |
| 150 |
|
|
| 151 |
if (mysql_query(db, "BEGIN") != 0) |
if (mysql_query(db, "BEGIN") != 0) |
| 152 |
{ |
{ |
| 153 |
log_error("Begin transaction failed\n"); |
log_error("Begin transaction error: %s\n", mysql_error(db)); |
| 154 |
|
mysql_close(db); |
| 155 |
return -1; |
return -1; |
| 156 |
} |
} |
| 157 |
|
|
| 166 |
ip_mask(client_addr, 1, '%')); |
ip_mask(client_addr, 1, '%')); |
| 167 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 168 |
{ |
{ |
| 169 |
log_error("Query user_list failed\n"); |
log_error("Query user_list error: %s\n", mysql_error(db)); |
| 170 |
|
mysql_close(db); |
| 171 |
return -1; |
return -1; |
| 172 |
} |
} |
| 173 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 174 |
{ |
{ |
| 175 |
log_error("Get user_list data failed\n"); |
log_error("Get user_list data failed\n"); |
| 176 |
|
mysql_close(db); |
| 177 |
return -1; |
return -1; |
| 178 |
} |
} |
| 179 |
if ((row = mysql_fetch_row(rs))) |
if ((row = mysql_fetch_row(rs))) |
| 181 |
if (atoi(row[0]) >= 2) |
if (atoi(row[0]) >= 2) |
| 182 |
{ |
{ |
| 183 |
mysql_free_result(rs); |
mysql_free_result(rs); |
| 184 |
|
mysql_close(db); |
| 185 |
|
|
| 186 |
prints("\033[1;31m来源存在多次失败登陆尝试,请稍后再试\033[m\r\n"); |
prints("\033[1;31m来源存在多次失败登陆尝试,请稍后再试\033[m\r\n"); |
|
iflush(); |
|
| 187 |
|
|
| 188 |
return 1; |
return 1; |
| 189 |
} |
} |
| 197 |
username); |
username); |
| 198 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 199 |
{ |
{ |
| 200 |
log_error("Query user_list failed\n"); |
log_error("Query user_list error: %s\n", mysql_error(db)); |
| 201 |
|
mysql_close(db); |
| 202 |
return -1; |
return -1; |
| 203 |
} |
} |
| 204 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 205 |
{ |
{ |
| 206 |
log_error("Get user_list data failed\n"); |
log_error("Get user_list data failed\n"); |
| 207 |
|
mysql_close(db); |
| 208 |
return -1; |
return -1; |
| 209 |
} |
} |
| 210 |
if ((row = mysql_fetch_row(rs))) |
if ((row = mysql_fetch_row(rs))) |
| 212 |
if (atoi(row[0]) >= 5) |
if (atoi(row[0]) >= 5) |
| 213 |
{ |
{ |
| 214 |
mysql_free_result(rs); |
mysql_free_result(rs); |
| 215 |
|
mysql_close(db); |
| 216 |
|
|
| 217 |
prints("\033[1;31m账户存在多次失败登陆尝试,请使用Web方式登录\033[m\r\n"); |
prints("\033[1;31m账户存在多次失败登陆尝试,请使用Web方式登录\033[m\r\n"); |
|
iflush(); |
|
| 218 |
|
|
| 219 |
return 1; |
return 1; |
| 220 |
} |
} |
| 227 |
username, password); |
username, password); |
| 228 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 229 |
{ |
{ |
| 230 |
log_error("Query user_list failed\n"); |
log_error("Query user_list error: %s\n", mysql_error(db)); |
| 231 |
|
mysql_close(db); |
| 232 |
return -1; |
return -1; |
| 233 |
} |
} |
| 234 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 235 |
{ |
{ |
| 236 |
log_error("Get user_list data failed\n"); |
log_error("Get user_list data failed\n"); |
| 237 |
|
mysql_close(db); |
| 238 |
return -1; |
return -1; |
| 239 |
} |
} |
| 240 |
if ((row = mysql_fetch_row(rs))) |
if ((row = mysql_fetch_row(rs))) |
| 241 |
{ |
{ |
| 242 |
BBS_uid = atol(row[0]); |
BBS_uid = atoi(row[0]); |
| 243 |
strncpy(BBS_username, row[1], sizeof(BBS_username) - 1); |
strncpy(BBS_username, row[1], sizeof(BBS_username) - 1); |
| 244 |
BBS_username[sizeof(BBS_username) - 1] = '\0'; |
BBS_username[sizeof(BBS_username) - 1] = '\0'; |
| 245 |
int p_login = atoi(row[2]); |
int p_login = atoi(row[2]); |
| 249 |
// Add user login log |
// Add user login log |
| 250 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 251 |
"INSERT INTO user_login_log(UID, login_dt, login_ip) " |
"INSERT INTO user_login_log(UID, login_dt, login_ip) " |
| 252 |
"VALUES(%ld, NOW(), '%s')", |
"VALUES(%d, NOW(), '%s')", |
| 253 |
BBS_uid, hostaddr_client); |
BBS_uid, hostaddr_client); |
| 254 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 255 |
{ |
{ |
| 256 |
log_error("Insert into user_login_log failed\n"); |
log_error("Insert into user_login_log error: %s\n", mysql_error(db)); |
| 257 |
|
mysql_close(db); |
| 258 |
return -1; |
return -1; |
| 259 |
} |
} |
| 260 |
|
|
| 261 |
// Commit transaction |
// Commit transaction |
| 262 |
if (mysql_query(db, "COMMIT") != 0) |
if (mysql_query(db, "COMMIT") != 0) |
| 263 |
{ |
{ |
| 264 |
log_error("Commit transaction failed\n"); |
log_error("Commit transaction error: %s\n", mysql_error(db)); |
| 265 |
|
mysql_close(db); |
| 266 |
return -1; |
return -1; |
| 267 |
} |
} |
| 268 |
|
|
| 269 |
if (p_login == 0) |
if (p_login == 0) |
| 270 |
{ |
{ |
| 271 |
mysql_free_result(rs); |
mysql_free_result(rs); |
| 272 |
|
mysql_close(db); |
| 273 |
|
|
| 274 |
prints("\033[1;31m您目前无权登陆...\033[m\r\n"); |
prints("\033[1;31m您目前无权登陆...\033[m\r\n"); |
|
iflush(); |
|
| 275 |
return 1; |
return 1; |
| 276 |
} |
} |
| 277 |
} |
} |
| 278 |
else |
else |
| 279 |
{ |
{ |
| 280 |
mysql_free_result(rs); |
mysql_free_result(rs); |
| 281 |
|
mysql_close(db); |
| 282 |
|
|
| 283 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 284 |
"INSERT INTO user_err_login_log(username, password, login_dt, login_ip) " |
"INSERT INTO user_err_login_log(username, password, login_dt, login_ip) " |
| 286 |
username, password, hostaddr_client); |
username, password, hostaddr_client); |
| 287 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 288 |
{ |
{ |
| 289 |
log_error("Insert into user_err_login_log failed\n"); |
log_error("Insert into user_err_login_log error: %s\n", mysql_error(db)); |
| 290 |
return -1; |
return -1; |
| 291 |
} |
} |
| 292 |
|
|
| 293 |
// Commit transaction |
// Commit transaction |
| 294 |
if (mysql_query(db, "COMMIT") != 0) |
if (mysql_query(db, "COMMIT") != 0) |
| 295 |
{ |
{ |
| 296 |
log_error("Commit transaction failed\n"); |
log_error("Commit transaction error: %s\n", mysql_error(db)); |
| 297 |
|
mysql_close(db); |
| 298 |
return -1; |
return -1; |
| 299 |
} |
} |
| 300 |
|
|
| 301 |
prints("\033[1;31m错误的用户名或密码...\033[m\r\n"); |
prints("\033[1;31m错误的用户名或密码...\033[m\r\n"); |
| 302 |
iflush(); |
mysql_close(db); |
| 303 |
return 1; |
return 1; |
| 304 |
} |
} |
| 305 |
|
|
| 306 |
// Set AUTOCOMMIT = 1 |
// Set AUTOCOMMIT = 1 |
| 307 |
if (mysql_query(db, "SET autocommit=1") != 0) |
if (mysql_query(db, "SET autocommit=1") != 0) |
| 308 |
{ |
{ |
| 309 |
log_error("SET autocommit=1 failed\n"); |
log_error("SET autocommit=1 error: %s\n", mysql_error(db)); |
| 310 |
|
mysql_close(db); |
| 311 |
return -1; |
return -1; |
| 312 |
} |
} |
| 313 |
|
|
| 319 |
break; |
break; |
| 320 |
case -1: // Load data error |
case -1: // Load data error |
| 321 |
prints("\033[1;31m读取用户数据错误...\033[m\r\n"); |
prints("\033[1;31m读取用户数据错误...\033[m\r\n"); |
| 322 |
iflush(); |
mysql_close(db); |
| 323 |
return -1; |
return -1; |
| 324 |
case -2: // Unused |
case -2: // Unused |
| 325 |
prints("\033[1;31m请通过Web登录更新用户许可协议...\033[m\r\n"); |
prints("\033[1;31m请通过Web登录更新用户许可协议...\033[m\r\n"); |
| 326 |
iflush(); |
mysql_close(db); |
| 327 |
return 1; |
return 1; |
| 328 |
case -3: // Dead |
case -3: // Dead |
| 329 |
prints("\033[1;31m很遗憾,您已经永远离开了我们的世界!\033[m\r\n"); |
prints("\033[1;31m很遗憾,您已经永远离开了我们的世界!\033[m\r\n"); |
| 330 |
iflush(); |
mysql_close(db); |
| 331 |
return 1; |
return 1; |
| 332 |
default: |
default: |
| 333 |
|
mysql_close(db); |
| 334 |
return -2; |
return -2; |
| 335 |
} |
} |
| 336 |
|
|
| 337 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 338 |
"UPDATE user_pubinfo SET visit_count = visit_count + 1, " |
"UPDATE user_pubinfo SET visit_count = visit_count + 1, " |
| 339 |
"last_login_dt = NOW() WHERE UID = %ld", |
"last_login_dt = NOW() WHERE UID = %d", |
| 340 |
BBS_uid); |
BBS_uid); |
| 341 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 342 |
{ |
{ |
| 343 |
log_error("Update user_pubinfo failed\n"); |
log_error("Update user_pubinfo error: %s\n", mysql_error(db)); |
| 344 |
|
mysql_close(db); |
| 345 |
return -1; |
return -1; |
| 346 |
} |
} |
| 347 |
|
|
| 348 |
if (user_online_add(db) != 0) |
if (user_online_add(db) != 0) |
| 349 |
{ |
{ |
| 350 |
|
mysql_close(db); |
| 351 |
return -1; |
return -1; |
| 352 |
} |
} |
| 353 |
|
|
| 354 |
BBS_last_access_tm = BBS_login_tm = time(0); |
BBS_last_access_tm = BBS_login_tm = time(0); |
| 355 |
|
|
| 356 |
|
// Set user tz to process env |
| 357 |
|
if (BBS_user_tz[0] != '\0') |
| 358 |
|
{ |
| 359 |
|
user_tz_env[0] = ':'; |
| 360 |
|
strncpy(user_tz_env + 1, BBS_user_tz, sizeof(user_tz_env) - 2); |
| 361 |
|
user_tz_env[sizeof(user_tz_env) - 1] = '\0'; |
| 362 |
|
|
| 363 |
|
if (setenv("TZ", user_tz_env, 1) == -1) |
| 364 |
|
{ |
| 365 |
|
log_error("setenv(TZ = %s) error %d\n", user_tz_env, errno); |
| 366 |
|
return -3; |
| 367 |
|
} |
| 368 |
|
|
| 369 |
|
tzset(); |
| 370 |
|
} |
| 371 |
|
|
| 372 |
|
mysql_close(db); |
| 373 |
|
|
| 374 |
return 0; |
return 0; |
| 375 |
} |
} |
| 376 |
|
|
| 377 |
int load_user_info(MYSQL *db, long int BBS_uid) |
int load_user_info(MYSQL *db, int BBS_uid) |
| 378 |
{ |
{ |
| 379 |
MYSQL_RES *rs; |
MYSQL_RES *rs; |
| 380 |
MYSQL_ROW row; |
MYSQL_ROW row; |
| 383 |
time_t last_login_dt; |
time_t last_login_dt; |
| 384 |
|
|
| 385 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 386 |
"SELECT life, UNIX_TIMESTAMP(last_login_dt) " |
"SELECT life, UNIX_TIMESTAMP(last_login_dt), user_timezone " |
| 387 |
"FROM user_pubinfo WHERE UID = %ld", |
"FROM user_pubinfo WHERE UID = %d", |
| 388 |
BBS_uid); |
BBS_uid); |
| 389 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 390 |
{ |
{ |
| 391 |
log_error("Query user_pubinfo failed\n"); |
log_error("Query user_pubinfo error: %s\n", mysql_error(db)); |
| 392 |
return -1; |
return -1; |
| 393 |
} |
} |
| 394 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 400 |
{ |
{ |
| 401 |
life = atoi(row[0]); |
life = atoi(row[0]); |
| 402 |
last_login_dt = (time_t)atol(row[1]); |
last_login_dt = (time_t)atol(row[1]); |
| 403 |
|
|
| 404 |
|
strncpy(BBS_user_tz, row[2], sizeof(BBS_user_tz) - 1); |
| 405 |
|
BBS_user_tz[sizeof(BBS_user_tz) - 1] = '\0'; |
| 406 |
} |
} |
| 407 |
else |
else |
| 408 |
{ |
{ |
| 425 |
return 0; |
return 0; |
| 426 |
} |
} |
| 427 |
|
|
| 428 |
int load_guest_info(MYSQL *db) |
int load_guest_info(void) |
| 429 |
{ |
{ |
| 430 |
|
MYSQL *db; |
| 431 |
|
|
| 432 |
|
db = db_open(); |
| 433 |
|
if (db == NULL) |
| 434 |
|
{ |
| 435 |
|
return -1; |
| 436 |
|
} |
| 437 |
|
|
| 438 |
strncpy(BBS_username, "guest", sizeof(BBS_username) - 1); |
strncpy(BBS_username, "guest", sizeof(BBS_username) - 1); |
| 439 |
BBS_username[sizeof(BBS_username) - 1] = '\0'; |
BBS_username[sizeof(BBS_username) - 1] = '\0'; |
| 440 |
|
|
| 450 |
|
|
| 451 |
BBS_last_access_tm = BBS_login_tm = time(0); |
BBS_last_access_tm = BBS_login_tm = time(0); |
| 452 |
|
|
| 453 |
|
mysql_close(db); |
| 454 |
|
|
| 455 |
return 0; |
return 0; |
| 456 |
} |
} |
| 457 |
|
|
| 466 |
|
|
| 467 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 468 |
"INSERT INTO user_online(SID, UID, ip, login_tm, last_tm) " |
"INSERT INTO user_online(SID, UID, ip, login_tm, last_tm) " |
| 469 |
"VALUES('Telnet_Process_%d', %ld, '%s', NOW(), NOW())", |
"VALUES('Telnet_Process_%d', %d, '%s', NOW(), NOW())", |
| 470 |
getpid(), BBS_priv.uid, hostaddr_client); |
getpid(), BBS_priv.uid, hostaddr_client); |
| 471 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 472 |
{ |
{ |
| 473 |
log_error("Add user_online failed\n"); |
log_error("Add user_online error: %s\n", mysql_error(db)); |
| 474 |
return -1; |
return -1; |
| 475 |
} |
} |
| 476 |
|
|
| 486 |
getpid()); |
getpid()); |
| 487 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 488 |
{ |
{ |
| 489 |
log_error("Delete user_online failed\n"); |
log_error("Delete user_online error: %s\n", mysql_error(db)); |
| 490 |
return -1; |
return -1; |
| 491 |
} |
} |
| 492 |
|
|