| 1 |
/*************************************************************************** |
/*************************************************************************** |
| 2 |
user_priv.h - description |
user_priv.h - description |
| 3 |
------------------- |
------------------- |
| 4 |
begin : Mon Oct 22 2004 |
Copyright : (C) 2004-2025 by Leaflet |
| 5 |
copyright : (C) 2004 by Leaflet |
Email : leaflet@leafok.com |
|
email : leaflet@leafok.com |
|
| 6 |
***************************************************************************/ |
***************************************************************************/ |
| 7 |
|
|
| 8 |
/*************************************************************************** |
/*************************************************************************** |
| 9 |
* * |
* * |
| 10 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
| 11 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
| 12 |
* the Free Software Foundation; either version 2 of the License, or * |
* the Free Software Foundation; either version 3 of the License, or * |
| 13 |
* (at your option) any later version. * |
* (at your option) any later version. * |
| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 18 |
#define _USER_PRIV_H_ |
#define _USER_PRIV_H_ |
| 19 |
|
|
| 20 |
#include "bbs.h" |
#include "bbs.h" |
| 21 |
#include <mysql.h> |
#include <mysql/mysql.h> |
| 22 |
|
|
| 23 |
// User privilege |
// User privilege |
| 24 |
#define S_NONE 0x0 |
#define S_NONE 0x0 |
| 50 |
{ |
{ |
| 51 |
int sid; |
int sid; |
| 52 |
int s_priv; |
int s_priv; |
| 53 |
|
int is_favor; |
| 54 |
} s_priv_list[BBS_max_section]; |
} s_priv_list[BBS_max_section]; |
| 55 |
int s_count; |
int s_count; |
| 56 |
}; |
}; |
| 59 |
|
|
| 60 |
extern BBS_user_priv BBS_priv; |
extern BBS_user_priv BBS_priv; |
| 61 |
|
|
| 62 |
extern int checklevel(BBS_user_priv *p_priv, int level); |
// Check whether user level matches any bit in the given param |
| 63 |
|
inline int checklevel(BBS_user_priv *p_priv, int level) |
| 64 |
|
{ |
| 65 |
|
if (level == P_GUEST) |
| 66 |
|
{ |
| 67 |
|
return 1; |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
return ((p_priv->level & level) ? 1 : 0); |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
// Check whether user level is equal or greater than the given param |
| 74 |
|
inline int checklevel2(BBS_user_priv *p_priv, int level) |
| 75 |
|
{ |
| 76 |
|
return ((p_priv->level >= level) ? 1 : 0); |
| 77 |
|
} |
| 78 |
|
|
| 79 |
|
extern int setpriv(BBS_user_priv *p_priv, int sid, int priv, int is_favor); |
| 80 |
|
|
| 81 |
extern int setpriv(BBS_user_priv *p_priv, int sid, int priv); |
extern int getpriv(BBS_user_priv *p_priv, int sid, int *p_is_favor); |
| 82 |
|
|
| 83 |
extern int getpriv(BBS_user_priv *p_priv, int sid); |
inline int checkpriv(BBS_user_priv *p_priv, int sid, int priv) |
| 84 |
|
{ |
| 85 |
|
int is_favor = 0; |
| 86 |
|
return (((getpriv(p_priv, sid, &is_favor) & priv)) == priv ? 1 : 0); |
| 87 |
|
} |
| 88 |
|
|
| 89 |
extern int checkpriv(BBS_user_priv *p_priv, int sid, int priv); |
inline int is_favor(BBS_user_priv *p_priv, int sid) |
| 90 |
|
{ |
| 91 |
|
int is_favor = 0; |
| 92 |
|
getpriv(p_priv, sid, &is_favor); |
| 93 |
|
return is_favor; |
| 94 |
|
} |
| 95 |
|
|
| 96 |
extern int load_priv(MYSQL *db, BBS_user_priv *p_priv, long int uid); |
extern int load_priv(MYSQL *db, BBS_user_priv *p_priv, long int uid); |
| 97 |
|
|