Home > Backend Development > PHP Tutorial > BBS design based on mysql 3_PHP tutorial

BBS design based on mysql 3_PHP tutorial

WBOY
Release: 2016-07-13 17:25:11
Original
922 people have browsed it

4. User module design
For the underlying database, the C API function of mysql is called to modify the database, and
certain state variables are saved internally (such as user name, or is it left to the upper layer?), and the upper layer is , then provide
user management interface.
Class UserManage {
private:
char myuserid[20]; // The user's id, which is empty before logging in
time logintime; // The user's login time is used to calculate the stay time
char loginhost[20]; //Site location.

public:
int NewUser( char *userid, char *passwd );
Create a new user and determine whether it already exists. Other information is temporarily empty.
Firstlogintime, permissions, etc. are missing. Save value.
int UserLogin( char *userid, char *passwd );
User login, verify password,
int ChangePasswd( char *oldpasswd, char *newpasswd );
Change password, the original password is required to be consistent.
int ChangePriData( char *newname, char *newemail,
char *newaddr );
Change basic data, name, email, address. . . .
int ModifyNumData( int addlogin, int addpost );
Modify the number of articles, number of visits to the site, and other data. . . . Pay attention to the calling object.
int UserLogout();
User logout, modify lastlogin, staytime, loginhost, etc.

// Ordinary query command
int QueryCommonData( const char * userid, int& loginnum,
char * username, int& postnum,
time& lastlogin, char *lasthost );


Query the basic information of netizens.

// Privilege instruction, the function first determines the permissions before completing the function.
int QueryPriData( const char * userid, char *email,
char *addr );
Query basic information, ordinary people can only check themselves, and privileged people can check other people.
int ModifyUserLevel( BOOL isAdd, unsigned long level );
Modify user permissions,
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 the user’s number of articles and other data.
int ModifyUserPasswd( char *userid, char *newpasswd );
Modify the user's password.
}
The above functions are not difficult. They all execute corresponding sql statements and access the mysql database.
Should general instructions be classified as privileged instructions? Should the permission check be placed at this level or the previous level?
This depends more on the focus of consideration, whether it is the clarity of the program or the simplicity of the code. It may be better to
look at the code. After all, the number of visits must be considered. In addition, whether the upper service layer should also consider permissions. What about checking
issues?

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532073.htmlTechArticle4. User module design For the underlying database, the C API function of mysql is called to modify the database, and certain state variables (such as user names) are stored internally, which is left to the upper layer to complete...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template