Dynamic Include Safety

前端 未结 4 1432
一向
一向 2021-01-14 14:05

Is there any way to safely include pages without putting them all in an array?

if (preg_match(\'/^[a-z0-9]+/\', $_GET[\'page\'])) {

$page = $_GET[\'page\'].\".ph         


        
4条回答
  •  爱一瞬间的悲伤
    2021-01-14 14:57

    You should never use user supplied information for includes. You should always have some sort of request handler that does this for you. While a regular expression may filter somethings it will not filter everything.

    If you do not want your site to get hacked you do not allow your users to control the flow of the application by designating an include.

提交回复
热议问题