Bbs Design Based on mysql (III)

Source: Internet
Author: User

4. User Module Design
For the underlying database, call mysql's c api function to modify the database and save it internally.
Certain status variables (for example, user name, or left to the previous layer for completion ?), The upper layer provides
User management interface.
Class UserManage {
Char myuserid [20]; // user id, empty before login
Time logintime; // user logon time, used to calculate the stay time
Char loginhost [20]; // The Origin Site.

Int NewUser (char * userid, char * passwd );
Create a new user and check whether there is any other information,
Set the default value for firstlogintime and permissions.
Int UserLogin (char * userid, char * passwd );
User Login, password verification,
Int ChangePasswd (char * oldpasswd, char * newpasswd );
Change the password. The original password must be consistent.
Int ChangePriData (char * newname, char * newemail,
Char * newaddr );
Change basic data, nickname, email, address ....
Int ModifyNumData (int addlogin, int addpost );
Modify the number of articles, the number of previous posts, and other data .... Pay attention to the call object.
Int UserLogout ();
The user exits and modifies lastlogin, staytime, and loginhost.

// Common query command
Int QueryCommonData (const char * userid, int & loginnum,
Char * username, int & postnum,
Time & lastlogin, char * lasthost );
Query basic user information.

// Privileged command. The function determines the permission before completing the function.
Int QueryPriData (const char * userid, char * email,
Char * addr );
Query basic information. Ordinary people can only query themselves. They have the privilege to query other people.
Int ModifyUserLevel (BOOL isAdd, unsigned long level );
Modify user permissions,
Int ModifyUserId (char * oldid, char * newid );
Char * newemail, char * newaddr );
Modify basic user data.
Int ModifyUserNumdata (char * userid, int addlogin, int addpost );
Modify the number of articles and other data.
Int ModifyUserPasswd (char * userid, char * newpasswd );
Modify the user password.
The preceding functions are not difficult. They execute corresponding SQL statements to access the mysql database,
Do you want to include general commands in privileged commands? Is the permission check on this layer or the previous layer?
It is more important to check whether the program is clear or the code is concise.
Check the code. After all, check the access traffic and whether the upper-layer service layer should also consider the permission check.
What's the problem?

Contact Us

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: 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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.