Re: [请益] 使用MySQL除了注意这些之外…

楼主: jonlee (Jon)   2017-11-05 23:24:49
※ 引述《red0whale (red whale)》之铭言:
: 我们在使用MySQL时都会注意SQL Injection和防止网页代码注入
: 也就是会使用addslashes和htmlspecialchars函数
: 在使用MySQL时除了要注意这两点之外
: 还有没有其他需要注意的?
: 另外,
: 在写上传档案的PHP程式时,
: 有时候为了防止使用者上传PHP档以攻击服务器内部而会阻止以“.php”为副档名的档案
: 除此之外,是否还有其他须注意的地方?
: 谢谢
htmlspecialchars 是在网页显示时,作 html escape 防止 XSS 等攻击使用
addslashes 建议不要使用,使用 mysql(i)_escape_string / mysql(i)_real_escape_string / PDO prepare.. 等等
原因在这边:https://stackoverflow.com/questions/4486016/whats-the-difference-between-phps-addslashes-and-mysqli-escape-string
至于安全性的部分,可以参考这篇:https://blog.longwin.com.tw/2008/08/php-sql-injection-xss-security-2008/

Links booklink

Contact Us: admin [ a t ] ucptt.com