基于mysql的bbs设计(四)_php基础
5。版面模块设计
所谓分类,更多的是为telnet服务端考虑的,在cq66模式下,用户可以按
照自己的意愿进行分类,反正最后都是直接以版为基本单位访问的。
对于版面文章的访问,存放的时候以整篇文章为参数,文章的分块由本层
完成,如果上层以块为单位传送,则在上层全部传完,组合后,再传参到本层
分解;在读取 的时候,本层则以块为单位访问,如果上层要以全文为单位访问
,则在上层做合并 工作,本层不管。
至于要不要独立出索引,不影响上层的操作,主要和下层的数据库构造有
关, 主要考虑可行性,效率需求等。
权限的检查放在哪里进行呢?还是放在上层吧,其实就telnet服务器端,
和cq66 的客户端,根本不会给一般用户显示特殊指令的菜单,当然,用户可
以直接发送cq66 的指令,服务器方还是要检查的。但应该不用在它下面的功
能模块层再检查一次吧
。 Class BoardManage {
private:
public:
// 有关分类的操作
int GetClassNameInfo( int maxclass, char **classid,
char ** classname );
返回分类的信息,中英文名。
int GetBoardName( int maxboards, char *classid,
char **boardname );
返回某分类中的版面信息,一般分类,直接select ..
from sboard
where boardclass == .... 特殊分类则查相应的表。。。。
// 修改需要版面管理员以上的特权
int NewClass( char * newclassname, int type );
新建分类,普通分类还是特殊分类,
int DeleteClass( char *newclassname );
删除分类,但不cascade,即本层不负责一致性,由上层负责将
相应的版面的分类信息改为别的。分类改名也是先删再建,
int AddClassBoard( const char *classname, char *newboardname );
将已建好的版加入某分类中,专门针对特殊分类,对一般分类,其
效果和modifyboardinfo一样,
int DeleteClassBoard( const char *classname, char *boardname );
从分类中删除某个版,也是针对特殊分类,对一般分类,效果也
是和modifyboardinfo一样,一个版的分类属性可以为空,即不属
于任何分类。
// 有关版的信息的操作。
int NewBoard( const char *boardid,char *boardname);
新建一个版,建立对应的表。其他参数取默认值。
int DeleteBoard( const char *boardid );
删除一个版,删除对应的表。
int GetBoardInfo( const char *boardid, char *boardname,
int& numposts, char *masters, char *class,
long &level );
取的版面的信息。
int ModifyBoardId( const char *oldid, char *newid );
改变版的英文id,对应table的名称也要改变,
int ModifyBoardInfo( const char *boardid, char *boardname,
int numposts, char *masters, char *class,
long level );
修改版面信息,需要特权。
// 有关版面文章的操作。
int AddText( char *boardid, char *title, char *writer,
char *text );
往版面中增加文章,内部将长文章分割成2k的块。
int DeleteText( char *boardid, int num );
删除文章,只是做一个标记,并不立刻修改对应的table。
int FlushTable( char *boardid );
刷新版面,删除被删文章的对应的记录。
int MarkText( char *boardid, int num, char mark );
给文章做标记。
int ModifyTitle( char *boardid, int num, char *newtitle );
修改文章的标题。
int ModifyText( char *boardid, int num, char *newtext );
修改文章内容,不是自己的文章需要特权。
int GetTextInfo( const char *boardid, int num, char *title,
char *writer, char& mark );
取得文章的标题信息。
int GetText( const char *boardid, int num, int block,
char *text );
读取文章的内容,以块为单位。
// 文章和作者的查询
// 一次将查询的结果全部返回?
int QueryWriter( const char *boardid, char *writer,
char **result );
查询版面上,某作者的文章。
int QueryTitle( const char *boardid, char *title,
char **result );
查询版面上,标题中包含指定内容的文章。
}
参数的传递是一件比较讨厌的事,从抽象的角度,希望返回的数据与
底层无关,所以应该加以处理,但从效率的角度,又不希望数据进行多次
复制,另一方面,空间的申请释放,究竟是在上层中完成还是在本层中完成
呢?一不小心,很容易有内存错误。

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

There are four main error types in PHP: 1.Notice: the slightest, will not interrupt the program, such as accessing undefined variables; 2. Warning: serious than Notice, will not terminate the program, such as containing no files; 3. FatalError: the most serious, will terminate the program, such as calling no function; 4. ParseError: syntax error, will prevent the program from being executed, such as forgetting to add the end tag.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

HTTP request methods include GET, POST, PUT and DELETE, which are used to obtain, submit, update and delete resources respectively. 1. The GET method is used to obtain resources and is suitable for read operations. 2. The POST method is used to submit data and is often used to create new resources. 3. The PUT method is used to update resources and is suitable for complete updates. 4. The DELETE method is used to delete resources and is suitable for deletion operations.

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The arrow function was introduced in PHP7.4 and is a simplified form of short closures. 1) They are defined using the => operator, omitting function and use keywords. 2) The arrow function automatically captures the current scope variable without the use keyword. 3) They are often used in callback functions and short calculations to improve code simplicity and readability.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.
