The BBS design based on MySQL (iii) _php tutorial

Source: Internet
Author: User
4. User module Design
For the underlying database, call the MySQL C API function to modify the database, internal storage
A certain state variable (such as a user name, or is it left to the previous layer to complete?) ), on the previous layer, provides
User-managed interfaces.
Class Usermanage {
Private
Char myuserid[20]; User ID, empty before login
Time Logintime; User login time, and used to calculate dwell time
Char loginhost[20]; The location of the station.

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 default values.
int Userlogin (char *userid, char *passwd);
User login, verify password,
int changepasswd (char *oldpasswd, char *newpasswd);
Change password, require the original password consistent.
int Changepridata (char *newname, Char *newemail,
Char *newaddr);
Change the basic data, Mud said, email, address ....
int modifynumdata (int addlogin, int addpost);
Modify the number of articles, the number of stations, and other data .... Note the calling object.
int Userlogout ();
User exit, modify Lastlogin,staytime,loginhost, etc.

General Query commands
int querycommondata (const char * userid, int& Loginnum,
char * username, int& Postnum,
time& Lastlogin, Char *lasthost);
Check the basic information of netizens.

Privileged directives, which determine permissions before the function is completed.
int querypridata (const char * userid, Char *email,
Char *addr);
Query basic information, ordinary people can only check themselves, have the privilege to check others.
int Modifyuserlevel (BOOL isadd, unsigned long level);
Modify the user's 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 data such as the number of articles for a user.
int modifyuserpasswd (char *userid, char *newpasswd);
Modify the user's password.
}
Each of these functions is not very difficult, is to execute the corresponding SQL statements, access to the MySQL database,
Will general directives be grouped into privileged directives? Is the check for permissions on this or the previous level?
This is more to look at the focus of consideration, is to see the clarity of the program or the code is concise, it may be
Look at the code, after all, to consider the amount of traffic, in addition, the upper layer of service should also consider the permission check
What about the problem?

http://www.bkjia.com/PHPjc/316256.html www.bkjia.com true http://www.bkjia.com/PHPjc/316256.html techarticle 4. User module design for the underlying database, call the MySQL C API function to make changes to the database, internal storage of certain state variables (such as user name, or left to the previous layer to complete ... )

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

    • 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.