| 85 |
if (db == NULL) |
if (db == NULL) |
| 86 |
return 1; |
return 1; |
| 87 |
|
|
| 88 |
// Admin |
// Permission |
| 89 |
sprintf(sql, "select aid,major from admin_config where UID=%ld" |
sprintf(sql, "SELECT p_post, p_msg FROM user_list WHERE UID = %ld AND verified", |
|
" and enable and (now() between begin_dt and end_dt)", |
|
| 90 |
uid); |
uid); |
| 91 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 92 |
{ |
{ |
| 93 |
log_error("Query admin_config failed\n"); |
log_error("Query user_list failed\n"); |
| 94 |
return -1; |
return -1; |
| 95 |
} |
} |
| 96 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 97 |
{ |
{ |
| 98 |
log_error("Get admin_config data failed\n"); |
log_error("Get user_list data failed\n"); |
| 99 |
return -1; |
return -1; |
| 100 |
} |
} |
| 101 |
if (row = mysql_fetch_row(rs)) |
if (row = mysql_fetch_row(rs)) |
| 102 |
{ |
{ |
| 103 |
p_priv->level |= (atoi(row[1]) ? P_ADMIN_M : P_ADMIN_S); |
p_priv->g_priv |= (atoi(row[0]) ? S_POST : 0); |
| 104 |
p_priv->g_priv |= (atoi(row[1]) ? S_ALL : S_ADMIN); |
p_priv->g_priv |= (atoi(row[1]) ? S_MSG : 0); |
| 105 |
} |
} |
| 106 |
mysql_free_result(rs); |
mysql_free_result(rs); |
| 107 |
|
|
| 108 |
// Permission |
// Admin |
| 109 |
sprintf(sql, "select p_post,p_msg,p_mail " |
sprintf(sql, "SELECT major FROM admin_config WHERE UID = %ld " |
| 110 |
"from user_list where UID=%ld", |
"AND enable AND (NOW() BETWEEN begin_dt AND end_dt)", |
| 111 |
uid); |
uid); |
| 112 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 113 |
{ |
{ |
| 114 |
log_error("Query user_list failed\n"); |
log_error("Query admin_config failed\n"); |
| 115 |
return -1; |
return -1; |
| 116 |
} |
} |
| 117 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 118 |
{ |
{ |
| 119 |
log_error("Get user_list data failed\n"); |
log_error("Get admin_config data failed\n"); |
| 120 |
return -1; |
return -1; |
| 121 |
} |
} |
| 122 |
if (row = mysql_fetch_row(rs)) |
if (row = mysql_fetch_row(rs)) |
| 123 |
{ |
{ |
| 124 |
p_priv->g_priv |= (atoi(row[0]) ? S_POST : 0); |
p_priv->level |= (atoi(row[1]) ? P_ADMIN_M : P_ADMIN_S); |
| 125 |
p_priv->g_priv |= (atoi(row[1]) ? S_MSG : 0); |
p_priv->g_priv |= (atoi(row[1]) ? S_ALL : S_ADMIN); |
|
p_priv->g_priv |= (atoi(row[2]) ? S_MAIL : 0); |
|
| 126 |
} |
} |
| 127 |
mysql_free_result(rs); |
mysql_free_result(rs); |
| 128 |
|
|
| 129 |
// Section Master |
// Section Master |
| 130 |
sprintf(sql, "select SID,major from section_master where" |
sprintf(sql, "SELECT section_master.SID, major FROM section_master " |
| 131 |
" UID=%ld and enable and (now() between begin_dt and" |
"INNER JOIN section_config ON section_master.SID = section_config.SID " |
| 132 |
" end_dt)", |
"WHERE UID = %ld AND section_master.enable AND section_config.enable " |
| 133 |
|
"AND (NOW() BETWEEN begin_dt AND end_dt)", |
| 134 |
uid); |
uid); |
| 135 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 136 |
{ |
{ |
| 150 |
mysql_free_result(rs); |
mysql_free_result(rs); |
| 151 |
|
|
| 152 |
// Section status |
// Section status |
| 153 |
sprintf(sql, "select SID,exp_get,read_user_level," |
sprintf(sql, "SELECT SID, exp_get, read_user_level, write_user_level FROM section_config " |
| 154 |
"write_user_level from section_config" |
"INNER JOIN section_class ON section_config.CID = section_class.CID " |
| 155 |
" left join section_class on section_config.CID=" |
"WHERE section_config.enable AND section_class.enable " |
| 156 |
"section_class.CID where section_config.enable and" |
"ORDER BY SID"); |
|
" section_class.enable order by SID"); |
|
| 157 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 158 |
{ |
{ |
| 159 |
log_error("Query section_config failed\n"); |
log_error("Query section_config failed\n"); |
| 166 |
} |
} |
| 167 |
while (row = mysql_fetch_row(rs)) |
while (row = mysql_fetch_row(rs)) |
| 168 |
{ |
{ |
| 169 |
|
int priv = getpriv(p_priv, atoi(row[0])); |
| 170 |
if (p_priv->level < atoi(row[2])) |
if (p_priv->level < atoi(row[2])) |
| 171 |
setpriv(p_priv, atoi(row[0]), |
{ |
| 172 |
getpriv(p_priv, atoi(row[0])) & (~S_LIST)); |
priv &= (~S_LIST); |
| 173 |
|
} |
| 174 |
if (p_priv->level < atoi(row[3])) |
if (p_priv->level < atoi(row[3])) |
| 175 |
setpriv(p_priv, atoi(row[0]), |
{ |
| 176 |
getpriv(p_priv, atoi(row[0])) & (~S_POST)); |
priv &= (~S_POST); |
| 177 |
|
} |
| 178 |
if (!atoi(row[1])) |
if (!atoi(row[1])) |
| 179 |
setpriv(p_priv, atoi(row[0]), |
{ |
| 180 |
getpriv(p_priv, atoi(row[0])) & (~S_GETEXP)); |
priv &= (~S_GETEXP); |
| 181 |
} |
} |
| 182 |
mysql_free_result(rs); |
setpriv(p_priv, atoi(row[0]), priv); |
|
|
|
|
// Section User priv |
|
|
sprintf(sql, "select SID,`read`,`write` from section_user_priv" |
|
|
" where UID=%ld order by SID", |
|
|
uid); |
|
|
if (mysql_query(db, sql) != 0) |
|
|
{ |
|
|
log_error("Query section_user_priv failed\n"); |
|
|
return -1; |
|
|
} |
|
|
if ((rs = mysql_store_result(db)) == NULL) |
|
|
{ |
|
|
log_error("Get section_user_priv data failed\n"); |
|
|
return -1; |
|
|
} |
|
|
while (row = mysql_fetch_row(rs)) |
|
|
{ |
|
|
setpriv(p_priv, atoi(row[0]), |
|
|
atoi(row[1]) ? (getpriv(p_priv, atoi(row[0])) | S_LIST) |
|
|
: (getpriv(p_priv, atoi(row[0])) & ~S_LIST)); |
|
|
setpriv(p_priv, atoi(row[0]), |
|
|
atoi(row[2]) ? (getpriv(p_priv, atoi(row[0])) | S_POST) |
|
|
: (getpriv(p_priv, atoi(row[0])) & ~S_POST)); |
|
| 183 |
} |
} |
| 184 |
mysql_free_result(rs); |
mysql_free_result(rs); |
| 185 |
|
|
| 186 |
// Section ban |
// Section ban |
| 187 |
sprintf(sql, "select SID from ban_user_list where" |
sprintf(sql, "SELECT SID FROM ban_user_list WHERE UID = %ld AND enable " |
| 188 |
" UID=%ld and enable and unban_UID=0 and" |
"AND (NOW() BETWEEN ban_dt AND unban_dt)", |
|
" (now() between ban_dt and unban_dt)", |
|
| 189 |
uid); |
uid); |
| 190 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 191 |
{ |
{ |