个人观点,说一下对 PHPCMS 的网站架构的看法
PHPCMS应该是国内第一家用MVC架构来写开源PHP产品的,我第一次工作上接触到PHPCMS是在两年前,那个时候对MVC还是不理解,然后因为工作需要,需要修改一下PHPCMS的源码。拿到代码后,我一开始还本着一种从PHPCMS入手来理解MVC模式,可研究了半天,心里一直想着这就是人人称赞的MVC架构吗?怎么而看都感觉不出哪里的优势,却让人很容易联想到discuz的架构。
(截图:phpcms的源码,来自文件D:\www\phpcms\phpcms\modules\content\content.php)
今天重新拿到PHPCMS的代码,重新看了下。
在自己理解了MVC,并且看过大部分的人气比较高的MVC框架,国内的ThinkPHP、国外的symfony2 laravel以及yii之后再来看PHPCMS,再来评价下PHPCMS:
1)结构混乱,命名没有任何规则,比如前台可以访问的加action前缀之类的。
2)有必要在开头第一段写上判断吗?为什么不直接用.htaccess禁止任何人访问 /phpcms这个目录?
3)phpsso_server 这个目录写法完全是抄袭discuz,拖油瓶。
4)phpcms一直宣称MVC,让人觉得技术上很厉害,但是实际上运行起来非常缓慢,卡得无比。
PHPCMS是用PHP4的架构思路来完成MVC模式。
今天重新看了PHPCMS的源码,才明白了自己当时为什么会有那种感受“这就是传说中人人称赞的MVC吗”,还对MVC产生排斥感。PHPCMS的写法完全是一种PHP4的写法,严格来说根本就不符合MVC规范,根本就不是MVC架构!最后要说的是,用PHP4的思路架构写出PHPCMS这样一个系统来,比用MVC写出来累,且维护成本比流行MVC框架开发出来的程序高(时间精力上)。(by default7#zbphp.com)

PHPsessionscanstorestrings,numbers,arrays,andobjects.1.Strings:textdatalikeusernames.2.Numbers:integersorfloatsforcounters.3.Arrays:listslikeshoppingcarts.4.Objects:complexstructuresthatareserialized.

TostartaPHPsession,usesession_start()atthescript'sbeginning.1)Placeitbeforeanyoutputtosetthesessioncookie.2)Usesessionsforuserdatalikeloginstatusorshoppingcarts.3)RegeneratesessionIDstopreventfixationattacks.4)Considerusingadatabaseforsessionstoragei

Session regeneration refers to generating a new session ID and invalidating the old ID when the user performs sensitive operations in case of session fixed attacks. The implementation steps include: 1. Detect sensitive operations, 2. Generate new session ID, 3. Destroy old session ID, 4. Update user-side session information.

PHP sessions have a significant impact on application performance. Optimization methods include: 1. Use a database to store session data to improve response speed; 2. Reduce the use of session data and only store necessary information; 3. Use a non-blocking session processor to improve concurrency capabilities; 4. Adjust the session expiration time to balance user experience and server burden; 5. Use persistent sessions to reduce the number of data read and write times.

PHPsessionsareserver-side,whilecookiesareclient-side.1)Sessionsstoredataontheserver,aremoresecure,andhandlelargerdata.2)Cookiesstoredataontheclient,arelesssecure,andlimitedinsize.Usesessionsforsensitivedataandcookiesfornon-sensitive,client-sidedata.

PHPidentifiesauser'ssessionusingsessioncookiesandsessionIDs.1)Whensession_start()iscalled,PHPgeneratesauniquesessionIDstoredinacookienamedPHPSESSIDontheuser'sbrowser.2)ThisIDallowsPHPtoretrievesessiondatafromtheserver.

The security of PHP sessions can be achieved through the following measures: 1. Use session_regenerate_id() to regenerate the session ID when the user logs in or is an important operation. 2. Encrypt the transmission session ID through the HTTPS protocol. 3. Use session_save_path() to specify the secure directory to store session data and set permissions correctly.

PHPsessionfilesarestoredinthedirectoryspecifiedbysession.save_path,typically/tmponUnix-likesystemsorC:\Windows\TemponWindows.Tocustomizethis:1)Usesession_save_path()tosetacustomdirectory,ensuringit'swritable;2)Verifythecustomdirectoryexistsandiswrita


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

WebStorm Mac version
Useful JavaScript development tools

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

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor
