P
P
PO6OT2015-04-07 18:02:27
PHP
PO6OT, 2015-04-07 18:02:27

How to prevent php files from accessing overlying folders (as in hosting)?

How to prevent php files from accessing overlying folders (as in hosting)? Preferably with htaccess.
Don't worry about eval(), it's disabled in the php.ini configuration. Shell access from PHP is also prohibited.
Each php file should only have access to child folders.
Explanation for the especially gifted:

spoiler
То есть если файл script1.php лежит по пути ./root/script1.php, то он не должен иметь доступ ни к каким файлам и папкам, кроме файлов и папок, находящихся в папке ./root/, ./root/foo/, ./root/foo/bar/, ./root/foo/bar/other/ и т.д.

А если файл script2.php лежит по пути ./root/foo/script2.php, то он не должен иметь доступ ни к каким файлам и папкам, кроме файлов и папок, находящихся в папке ./root/foo/, ./root/foo/bar/, ./root/foo/bar/other/ и т.д.

Таким образом файл ./root/script1.php может знать, что в директории ./root/foo/ находится script2.php и может его удалить, а script2.php не может ни того ни другого, он может делать то-же самое только в своей и в дочерних папках.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry Entelis, 2015-04-07
@woonem

stackoverflow.com/questions/12591547/restrict-phps...

F
FanatPHP, 2015-04-07
@FanatPHP

With self-confidence worthy of a better use, you ask illiterate questions, and demand that you present all of computer science in questions and answers, and even at a level accessible to you, given the limitations of your shit architecture.
At the same time, with a very high probability, the answer will not be useful to you - either because of the mentioned rogue architecture, or because you are asking - again, from monstrous illiteracy - not at all what you need.
Do you want to know how hosting does?
There are HUNDREDS of options. From stupid file permissions and shit to separate virtual machines for users. Taking into account the specific requirements in each case. Do you want to know how? Read books! If you think that a 12-year-old snot can build a system by asking a couple of questions on a toaster, then I have to disappoint you. Even programmers with ten years of experience do not configure the environment - this is done by people specially trained in their specialty. Which also spent 10 years.
Do you want a literal answer to your question? please study
https://www.linux.com/learn/tutorials/309527-under
...
Learn to ask adequate questions and adequately respond to criticism of your slanderous ideas.

S
SagePtr, 2015-04-07
@SagePtr

Run php as a user who does not have access to these folders

X
xmoonlight, 2015-04-07
@xmoonlight

Permissions and running scripts as different users:
suEXEC

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question