基于mysql的bbs设计三
4。用户模块设计
对于底层数据库,调用mysql的C API函数来进行数据库的修改,内部保存
一定的状态变量(例如用户名,还是留给上一层完成?),对上一层,则提供
用户管理的接口。
Class UserManage {
private:
char myuserid[20]; // 用户的id,未登陆前为空
time logintime; // 用户登陆时间,并用于计算停留时间
char loginhost[20]; //上站地点。
public:
int NewUser( char *userid, char *passwd );
新建一个用户,判断是否已经有,其他资料暂时为空,
firstlogintime,权限等设缺省值。
int UserLogin( char *userid, char *passwd );
用户登陆,验证密码,
int ChangePasswd( char *oldpasswd, char *newpasswd );
修改密码,要求原密码一致。
int ChangePriData( char *newname, char *newemail,
char *newaddr );
改变基本数据,泥称,email,住址。。。。
int ModifyNumData( int addlogin, int addpost );
修改文章数,上站次数,等数据。。。。注意调用对象。
int UserLogout();
用户退出,修改lastlogin,staytime,loginhost等
// 普通查询命令
int QueryCommonData( const char * userid, int& loginnum,
char * username, int& postnum,
time& lastlogin, char *lasthost );
查询网友基本信息。
// 特权指令,函数在完成功能前,先判断权限。
int QueryPriData( const char * userid, char *email,
char *addr );
查询基本信息,普通人只能查自己,有特权才能查其他人。
int ModifyUserLevel( BOOL isAdd, unsigned long level );
修改用户的权限,
int ModifyUserId( char *oldid, char *newid );
char *newemail, char *newaddr );
修改用户的基本数据。
int ModifyUserNumdata( char *userid, int addlogin, int addpost );
修改用户的文章数等数据。
int ModifyUserPasswd( char *userid, char *newpasswd );
修改用户的密码。
}
以上各个函数难度不大,都是执行相应的sql语句,访问mysql数据库,
是否将一般指令归到特权指令中去呢?权限的检查,是放在这一层还是上一层?
这更多的是看考虑的着重点,是看程序的清晰性还是代码的简练,可能还是
看代码吧,毕竟要考虑访问量,另外,上层服务层是否也应该考虑权限检查
问题呢?

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version
Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
