| 3 |
* user_priv |
* user_priv |
| 4 |
* - basic operations of user privilege |
* - basic operations of user privilege |
| 5 |
* |
* |
| 6 |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
* Copyright (C) 2004-2026 Leaflet <leaflet@leafok.com> |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
|
#ifdef HAVE_CONFIG_H |
| 10 |
|
#include "config.h" |
| 11 |
|
#endif |
| 12 |
|
|
| 13 |
#include "bbs.h" |
#include "bbs.h" |
| 14 |
#include "common.h" |
#include "common.h" |
| 15 |
#include "database.h" |
#include "database.h" |
| 17 |
#include "user_priv.h" |
#include "user_priv.h" |
| 18 |
#include <stdio.h> |
#include <stdio.h> |
| 19 |
#include <stdlib.h> |
#include <stdlib.h> |
| 20 |
#include <mysql/mysql.h> |
#include <mysql.h> |
| 21 |
|
|
| 22 |
BBS_user_priv BBS_priv; |
BBS_user_priv BBS_priv; |
| 23 |
|
|
| 24 |
|
// External definitions for inline functions |
| 25 |
|
extern inline int checklevel(BBS_user_priv *p_priv, int level); |
| 26 |
|
extern inline int checklevel2(BBS_user_priv *p_priv, int level); |
| 27 |
|
extern inline int checkpriv(BBS_user_priv *p_priv, int sid, int priv); |
| 28 |
|
extern inline int is_favor(BBS_user_priv *p_priv, int sid); |
| 29 |
|
|
| 30 |
inline static int search_priv(BBS_user_priv *p_priv, int sid, int *p_offset) |
inline static int search_priv(BBS_user_priv *p_priv, int sid, int *p_offset) |
| 31 |
{ |
{ |
| 32 |
int left = 0; |
int left = 0; |
| 132 |
uid); |
uid); |
| 133 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 134 |
{ |
{ |
| 135 |
log_error("Query user_list error: %s\n", mysql_error(db)); |
log_error("Query user_list error: %s", mysql_error(db)); |
| 136 |
return -1; |
return -1; |
| 137 |
} |
} |
| 138 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 139 |
{ |
{ |
| 140 |
log_error("Get user_list data failed\n"); |
log_error("Get user_list data failed"); |
| 141 |
return -1; |
return -1; |
| 142 |
} |
} |
| 143 |
if ((row = mysql_fetch_row(rs))) |
if ((row = mysql_fetch_row(rs))) |
| 154 |
uid); |
uid); |
| 155 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 156 |
{ |
{ |
| 157 |
log_error("Query admin_config error: %s\n", mysql_error(db)); |
log_error("Query admin_config error: %s", mysql_error(db)); |
| 158 |
return -1; |
return -1; |
| 159 |
} |
} |
| 160 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 161 |
{ |
{ |
| 162 |
log_error("Get admin_config data failed\n"); |
log_error("Get admin_config data failed"); |
| 163 |
return -1; |
return -1; |
| 164 |
} |
} |
| 165 |
if ((row = mysql_fetch_row(rs))) |
if ((row = mysql_fetch_row(rs))) |
| 178 |
uid); |
uid); |
| 179 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 180 |
{ |
{ |
| 181 |
log_error("Query section_master error: %s\n", mysql_error(db)); |
log_error("Query section_master error: %s", mysql_error(db)); |
| 182 |
return -1; |
return -1; |
| 183 |
} |
} |
| 184 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 185 |
{ |
{ |
| 186 |
log_error("Get section_master data failed\n"); |
log_error("Get section_master data failed"); |
| 187 |
return -1; |
return -1; |
| 188 |
} |
} |
| 189 |
while ((row = mysql_fetch_row(rs))) |
while ((row = mysql_fetch_row(rs))) |
| 202 |
"ORDER BY SID"); |
"ORDER BY SID"); |
| 203 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 204 |
{ |
{ |
| 205 |
log_error("Query section_config error: %s\n", mysql_error(db)); |
log_error("Query section_config error: %s", mysql_error(db)); |
| 206 |
return -1; |
return -1; |
| 207 |
} |
} |
| 208 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 209 |
{ |
{ |
| 210 |
log_error("Get section_config data failed\n"); |
log_error("Get section_config data failed"); |
| 211 |
return -1; |
return -1; |
| 212 |
} |
} |
| 213 |
while ((row = mysql_fetch_row(rs))) |
while ((row = mysql_fetch_row(rs))) |
| 236 |
uid); |
uid); |
| 237 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 238 |
{ |
{ |
| 239 |
log_error("Query ban_user_list error: %s\n", mysql_error(db)); |
log_error("Query ban_user_list error: %s", mysql_error(db)); |
| 240 |
return -1; |
return -1; |
| 241 |
} |
} |
| 242 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 243 |
{ |
{ |
| 244 |
log_error("Get ban_user_list data failed\n"); |
log_error("Get ban_user_list data failed"); |
| 245 |
return -1; |
return -1; |
| 246 |
} |
} |
| 247 |
while ((row = mysql_fetch_row(rs))) |
while ((row = mysql_fetch_row(rs))) |
| 257 |
uid); |
uid); |
| 258 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 259 |
{ |
{ |
| 260 |
log_error("Query section_favorite error: %s\n", mysql_error(db)); |
log_error("Query section_favorite error: %s", mysql_error(db)); |
| 261 |
return -1; |
return -1; |
| 262 |
} |
} |
| 263 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 264 |
{ |
{ |
| 265 |
log_error("Get section_favorite data failed\n"); |
log_error("Get section_favorite data failed"); |
| 266 |
return -1; |
return -1; |
| 267 |
} |
} |
| 268 |
while ((row = mysql_fetch_row(rs))) |
while ((row = mysql_fetch_row(rs))) |