php - open_basedir allow including "trusted" code -


i writing application want allow users write / run / test code on server, preloaded code application. want these users able work in directory , task can done open_basedir();, problem if want include application's code permission denied if require or include inside function or class file not included before open_basedir called.

example :

<?php  function test() {     require 'test.php'; }  test(); // ok  ini_set('open_basedir', 'users/username/');  test(); // permission denied 

is possible somehow allow "trusted" code of application included don't allow user's code access directories? , if possible, give me example or main idea on how can resolve this, if not related open_basedir()

in example, not have permission denied. give me possibility add great features application.

another example :

spl_autoload_register(function($class) {     require $class . '.php'; });  ini_set('open_basedir', 'folder/');  new test(); // warning: require(): open_basedir restriction in effect. 

well, if there no solution, present own.

i sure not best way, works expected.

first of all, users have option write/run custom code have upload server, or write on website (then save), have check code before save, imitates sandbox, abstractization of application. next run code in sandbox (with modified open_basedir limitation) , if code has no fatal errors (and have not modified files in working directory [if modified, these files checked]) saved. after user have option run code in real application.

cons :

  • abstractization of entire application (on every change in application's structure)

pros :

  • allow third party code access files / functions / classes want
  • block features / methods unknown code should not access
  • securely execute unknown code
  • no need check code on every execution
  • no external libraries required

Comments

Popular posts from this blog

.htaccess - htaccess convert request to clean url and add slash at the end of the url -

C# random value from dictionary and tuple -

algorithm - Testing tetrahedron-triangle intersection -