4. User module Design
For the underlying database, call the MySQL C API function for database modification, internal save
A certain state variable (for example, user name, or leave it to the previous level?) ), on the previous layer, provides
User-managed interfaces.
Class Usermanage {
Private
Char myuserid[20]; ID of the user, empty before landing
Time Logintime; User login time, and used to calculate residence time
Char loginhost[20]; The station location.
Public
int NewUser (char *userid, char *passwd);
Create a new user to determine if there is already, other information is temporarily empty,
Firstlogintime, permissions, etc. set the default values.
int Userlogin (char *userid, char *passwd);
User login, verify password,
int changepasswd (char *oldpasswd, char *newpasswd);
Changes the password, requests the original password to be consistent.
int Changepridata (char *newname, Char *newemail,
Char *newaddr);
Change the basic data, Mud said, email, address ....
int modifynumdata (int addlogin, int addpost);
Change the number of articles, the number of stations, and other data .... Notice the calling object.
int Userlogout ();
User exit, modify Lastlogin,staytime,loginhost etc.
Normal query command
int querycommondata (const char * userid, int& Loginnum,
char * username, int& Postnum,
time& Lastlogin, Char *lasthost);
Check the basic information of users.
Privileged instruction, the function before completing the function, first judge the permission.
int querypridata (const char * userid, Char *email,
Char *addr);
Check the basic information, ordinary people can only check themselves, have the privilege to check other people.
int Modifyuserlevel (BOOL isadd, unsigned long level);
Modify the permissions of the user,
int Modifyuserid (char *oldid, char *newid);
Char *newemail, char *newaddr);
Modify the user's basic data.
int Modifyusernumdata (char *userid, int addlogin, int addpost);
Modify data such as the number of users ' articles.
int modifyuserpasswd (char *userid, char *newpasswd);
Modify the user's password.
}
The above function is not very difficult, is to execute the corresponding SQL statements, access to the MySQL database,
Do you want to assign general instructions to a privileged command? Permission check, is it on this floor or on the upper level?
This is more to see the focus of consideration, is to see the clarity of the program or code concise, may or
Look at the code, after all, to consider the number of visits, in addition, the upper level of service layer should also consider permission to check
What's the problem?
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service