Hello. I do something like a site with a PHP code editor. When I click on the browse key, a folder with a unique id is created in my special directory and in it a file with the php code itself (example: /_projects/6dfh78d76dfg87/index.php ). Further this page opens in iframe .
So to the problem: faced with a security problem. From the created file you can edit any site file (.htaccess and other site files). I sketched a couple of options on how to limit access to the files on my site:
- Protect changing and deleting important files (but here's a drawback: you can edit the files of someone else's "project")
- Prevent files from the
/_projects/{ID}/directory from accessing files that are outside the {ID} folder - Disallow some functions in PHP
- Hide directories and files from functions such as
scandir,dirname... - Check PHP file for prohibited functions.
But I do not know how to implement these options. Tell me, how can they be implemented or does someone know a better option? I would be very grateful. Thank you in advance.
../- such ways and compare with the ways? but in general, if you look at sandbox.onlinephpfunctions.com , they, when running the script, prohibit functions such as opendir and so on in php.ini: disable_functions = - Orange_shadow