/[LeafOK_CVS]/lbbs/src/user_priv.c
ViewVC logotype

Diff of /lbbs/src/user_priv.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.5 by sysadm, Mon Apr 28 03:31:00 2025 UTC Revision 1.6 by sysadm, Mon Apr 28 04:23:38 2025 UTC
# Line 71  int checkpriv(BBS_user_priv *p_priv, int Line 71  int checkpriv(BBS_user_priv *p_priv, int
71          return (((getpriv(p_priv, sid) & priv)) ^ priv ? 0 : 1);          return (((getpriv(p_priv, sid) & priv)) ^ priv ? 0 : 1);
72  }  }
73    
74  int load_priv(MYSQL *db, BBS_user_priv *p_priv, long int uid,  int load_priv(MYSQL *db, BBS_user_priv *p_priv, long int uid)
                           long int auth_uid, int priv_excluse)  
75  {  {
76          MYSQL_RES *rs;          MYSQL_RES *rs;
77          MYSQL_ROW row;          MYSQL_ROW row;
# Line 80  int load_priv(MYSQL *db, BBS_user_priv * Line 79  int load_priv(MYSQL *db, BBS_user_priv *
79          int i;          int i;
80    
81          p_priv->uid = uid;          p_priv->uid = uid;
         p_priv->auid = auth_uid;  
82          p_priv->level = (uid == 0 ? P_GUEST : P_USER);          p_priv->level = (uid == 0 ? P_GUEST : P_USER);
         p_priv->level |= (auth_uid == 0 ? P_GUEST : P_AUTH_USER);  
83          p_priv->g_priv = S_DEFAULT;          p_priv->g_priv = S_DEFAULT;
84    
85          if (db == NULL)          if (db == NULL)
# Line 131  int load_priv(MYSQL *db, BBS_user_priv * Line 128  int load_priv(MYSQL *db, BBS_user_priv *
128          }          }
129          mysql_free_result(rs);          mysql_free_result(rs);
130    
         // Verified  
         sprintf(sql, "select verified from user_list where"  
                                  " UID=%ld",  
                         uid);  
         if (mysql_query(db, sql) != 0)  
         {  
                 log_error("Query user_list failed\n");  
                 return -1;  
         }  
         if ((rs = mysql_store_result(db)) == NULL)  
         {  
                 log_error("Get user_list data failed\n");  
                 return -1;  
         }  
         if (row = mysql_fetch_row(rs))  
                 p_priv->g_priv &= (atoi(row[0]) ? p_priv->g_priv : S_DEFAULT);  
         mysql_free_result(rs);  
   
         // IP ban  
         sprintf(sql, "select begin_ip,end_ip from ban_ip_list"  
                                  " where ('%s' between begin_ip and end_ip) and enable",  
                         hostaddr_client);  
         if (mysql_query(db, sql) != 0)  
         {  
                 log_error("Query ban_ip_list failed\n");  
                 return -1;  
         }  
         if ((rs = mysql_store_result(db)) == NULL)  
         {  
                 log_error("Get ban_ip_list data failed\n");  
                 return -1;  
         }  
         if (mysql_num_rows(rs) > 0)  
                 p_priv->g_priv &= S_DEFAULT;  
         mysql_free_result(rs);  
   
         // Section Class Master  
         sprintf(sql, "select SID from section_class_master"  
                                  " left join section_config on section_class_master.CID"  
                                  "=section_config.CID where UID=%ld and section_class_master.enable"  
                                  " and (now() between begin_dt and end_dt)",  
                         uid);  
         if (mysql_query(db, sql) != 0)  
         {  
                 log_error("Query section_class_master failed\n");  
                 return -1;  
         }  
         if ((rs = mysql_store_result(db)) == NULL)  
         {  
                 log_error("Get section_class_master data failed\n");  
                 return -1;  
         }  
         while (row = mysql_fetch_row(rs))  
         {  
                 p_priv->level |= P_MAN_C;  
                 setpriv(p_priv, atoi(row[0]), getpriv(p_priv, atoi(row[0])) | S_MAN_M);  
         }  
         mysql_free_result(rs);  
   
131          // Section Master          // Section Master
132          sprintf(sql, "select SID,major from section_master where"          sprintf(sql, "select SID,major from section_master where"
133                                   " UID=%ld and enable and (now() between begin_dt and"                                   " UID=%ld and enable and (now() between begin_dt and"
# Line 289  int load_priv(MYSQL *db, BBS_user_priv * Line 227  int load_priv(MYSQL *db, BBS_user_priv *
227          }          }
228          mysql_free_result(rs);          mysql_free_result(rs);
229    
         // Priv exclusion  
         p_priv->g_priv &= (~priv_excluse);  
         for (i = 0; i < p_priv->s_count; i++)  
                 p_priv->s_priv_list[i].s_priv &= (~priv_excluse);  
   
         if (priv_excluse & S_MAN_M)  
                 p_priv->level &= (P_AUTH_USER | P_USER);  
   
230          return 0;          return 0;
231  }  }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1