Design of BBS based on MySQL (2)

Source: Internet
Author: User
Tags empty modify mysql access mysql database

4. User module Design

For the underlying database, call the MySQL C API function to make database modifications, internally save a certain state variables (such as user name, or left to the previous layer to complete?) To the previous layer, the user-managed interface is provided.

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 functions are not very difficult, are the implementation of the corresponding SQL statements, access to the MySQL database, whether the general instructions to the privileged instructions to go? 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 still look at the code, after all, to consider the number of visits, in addition, the upper layer of service should also consider the issue of permission check?

5. Layout module Design

The so-called classification, more is for Telnet service side to consider, in cq66 mode, users can according to their wishes to classify, anyway finally are directly to version for the basic unit access.

For the access to the layout article, the time to store the whole article as a parameter, the article is divided into pieces by this layer, if the upper layer is transmitted in blocks, then all the upper layers are passed, combined, then transferred to the level of decomposition; At the time of reading, this layer is accessed as a block, and if the upper level is to be accessed in full text, the upper part does the merging work , this layer does not matter.

As for the independent index, does not affect the upper level of operation, mainly with the underlying database structure, the main consideration of feasibility, efficiency requirements.

Where does the permission check go? Or put on the top bar, in fact, Telnet server side, and cq66 client, will not give the general user to display special instructions menu, of course, users can send cq66 instructions directly, server side or to check. But you should not check it again at the functional module layer below it. 1 2 Next page > full text reading tips: Try "←→" button, turn the page more convenient Oh!

Related Article

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.