For example directory named test
placed .htacess with the only code in the first line php_flag engine off
In directory test
placed file test.php
with this code echo 1+3;
And in another file (main.php
) placed include("test.php");
Open main.php
and see 4
(result of 1+3).
Added AddType text/plain .php .phtml .php3
. The same result.
I expected because of php_flag engine off
code in test.php
would not execute.
What need to do to prevent to execute code in test.php
?
Trying to prevent situation when hacker in images directory somehow uploads php file, then either directly access to the file or includes the file in another file.
Measures:
1) Created multiple validations to check if uploaded file is image and does not contains some php code.
2) Disabled direct access to images directory (in htaccess)
3) To be quite sure that hacker could not include uploaded php file in a file in another directory, as understand must set read only to all directories, except images directory