Is there any way to lock access to some built-in php functions, eg rmdir(), and make permission to some other function/method/object to access it?
Is there any way to lock access to some built-in php functions, eg rmdir()
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can override functions with runkit_function_redefine, but you must also set
runkit.internal_overridein php.ini otherwise you can only override functions in user space.Once you have overridden
rmdir()you can make it do anything you want: Do nothing, only work in certain directories, only work when there is a session variable set, etc…I haven’t tried ADP before, but you could also use override_function and rename_function. You could rename
rmdir()tormdir_hidden()and override the built-in name to call the new name given certain conditions. It would still be possible to callrmdir_hidden(), but only if the coder knows what it has been renamed to.By the way – I don’t think it’s really a good idea to be redefining built-in functions in PHP. Maybe before you implement this, you should take a good look at what you are doing and why you’re doing it. In all the PHP projects I’ve worked on, I’ve never seen or considered overriding a built-in function.