4. The user module is designed to call mysql's CAPI function to modify the database for the underlying database, and save certain state variables (such as the user name or left to the previous layer for modification ?), The upper layer provides user management interfaces. ClassUserManage {private: charmyuserid [20]; User id, empty before login t
4. The user module is designed to call the mysql c api function for database modification for the underlying database, and save certain state variables (such as the user name or left to the previous layer for modification ?), The upper layer provides user management interfaces. Class UserManage {private: char myuserid [20]; // user id. It is blank before login. t
4. User Module Design
For the underlying database, call mysql's c api function to modify the database, and save certain state variables (such as the user name or left to the previous layer for completion ?), The upper layer provides user management interfaces.
Class UserManage {
Private:
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.
Public:
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 all execute corresponding SQL statements and access the mysql database. Do you want to classify General commands into privileged commands? Is the permission check on this layer or the previous layer?
This focuses more on the program's clarity or code's conciseness. Maybe you should check the code. After all, you should consider the access traffic. In addition, should the upper-layer service layer also consider permission check issues?
5. Layout module design
The so-called classification is more important for the telnet server. In cq66 mode, users can classify the data according to their own wishes. In the end, the data is directly accessed based on the version.
For access to layout articles, the entire article is stored as a parameter. The sections of the article are completed by the current layer. If the upper layer is transmitted in blocks, all sections are transmitted at the upper layer. After the combination, then pass the parameter to the current layer for decomposition. During reading, the current layer accesses data in blocks. If the upper layer accesses data in full text, merge the data at the upper layer, this layer does not matter.
Whether or not to independently produce indexes does not affect upper-layer operations. It is mainly related to the structure of lower-layer databases and mainly considers feasibility and efficiency requirements.
Where can I check permissions? Put it on the upper layer. In fact, the telnet server and the cq66 client won't display the menu of special commands to the general user. Of course, the user can directly send the command of cq66, the server still needs to check. But you do not need to check it again at the function module layer below it.
Class BoardManage {
Private:
Public:
// Operation on Classification
Int GetClassNameInfo (int maxclass, char ** classid,
Char ** classname );
Returns the category information, which is a Chinese name.
Int GetBoardName (int maxboards, char * classid,
Char ** boardname );
Returns the layout information of a category. Generally, the layout information is directly selected ..
From sboard
Where boardclass =... for special classification, query the corresponding table ....
// Modify the privileges above the layout Administrator
Int NewClass (char * newclassname, int type );
New category, general category or special category,
Int DeleteClass (char * newclassname );
This layer is not responsible for consistency, and the upper layer is responsible
The category information of the corresponding layout is changed to another one. The category name is also deleted first and then created,
Int AddClassBoard (const char * classname, char * newboardname );
Adds an existing version to a specific category, specifically for a special category.
The effect is the same as that of modifyboardinfo,
Int DeleteClassBoard (const char * classname, char * boardname );
Deleting a version from a category also applies to special categories.
Is the same as modifyboardinfo, the classification attribute of a version can be empty, that is, not
In any category.
// Operations on version information.
Int NewBoard (const char * boardid, char * boardname );
Create a new version and create a corresponding table. For other parameters, use the default value.
Int DeleteBoard (const char * boardid );
Delete A version and delete the corresponding table.
Int GetBoardInfo (const char * boardid, char * boardname,
Int & numposts, char * masters, char * class,
Long & level );
The layout information.
Int ModifyBoardId (const char * oldid, char * newid );
Change the English version id. The table name must also be changed,
Int ModifyBoardInfo (const char * boardid, char * boardname,
Int numposts, char * masters, char * class,
Long level );
Privilege is required to modify layout information.
// Operations on the layout.
Int AddText (char * boardid, char * title, char * writer,
Char * text );
Add an article to the layout and divide the long article into 2 k blocks.
Int DeleteText (char * boardid, int num );
Deleting an article only makes a tag and does not immediately modify the corresponding table.
Int FlushTable (char * boardid );
Refresh the layout and delete the corresponding records of the deleted article.
Int MarkText (char * boardid, int num, char mark );
Mark the article.
Int ModifyTitle (char * boardid, int num, char * newtitle );
Modify the title of an article.
Int ModifyText (char * boardid, int num, char * newtext );
Modifying the content of an article does not require the privilege of your own article.
Int GetTextInfo (const char * boardid, int num, char * title,
Char * writer, char & mark );
Obtain the title information of an article.
Int GetText (const char * boardid, int num, int block,
Char * text );
Reads the content of an article, in blocks.
// Query of articles and authors
// Return all query results at one time?
Int QueryWriter (const char * boardid, char * writer,
Char ** result );
Query an author's article on the layout.
Int QueryTitle (const char * boardid, char * title,
Char ** result );
On the query page, the title contains the specified content.
}
Parameter passing is a very annoying thing. From an abstract point of view, you want
It is irrelevant to the underlying layer, so it should be processed. However, from the perspective of efficiency, data is not expected to be processed multiple times.
Replication, on the other hand, whether the application for space release is completed in the upper layer or in the current Layer
What about it? Accidentally, memory errors may easily occur.