note 93347 added to function.include

From: Date: Fri, 04 Sep 2009 16:59:36 +0000
Subject: note 93347 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-160216@lists.php.net to get a copy of this message
A even better security solution is to do the following: $path = basename($page, 'php') . '.php'; if(file_exists($path)) include $path; This will mean it will only load files with the ".php" extension in the current directory. Eg $page = 'myfile.php' => 'myfile.php' $page = '/etc/passwd' => 'passwd.php' => not found $page = 'myfile.jpg' => 'myfile.jpg.php' => not found Simple. Richard ---- Server IP: 92.48.74.199 Probable Submitter: 82.17.131.125 ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- https://master.php.net/note/edit/93347 Del: integrated -- https://master.php.net/note/delete/93347/integrated Del: useless -- https://master.php.net/note/delete/93347/useless Del: bad code -- https://master.php.net/note/delete/93347/bad+code Del: spam -- https://master.php.net/note/delete/93347/spam Del: non-english -- https://master.php.net/note/delete/93347/non-english Del: in docs -- https://master.php.net/note/delete/93347/in+docs Del: other reasons-- https://master.php.net/note/delete/93347 Reject -- https://master.php.net/note/reject/93347 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#160216) next »