I am making a program that will run a persons C++ code from PHP. How can I compile, run, return the output of a C++ program securly? By securly I mean how can I do it without making my system vulnerable to hackers? I guess I would just use the exec comman to GCC to compile the program then run the program using exec. But how can I do this securly?
Share
This is something just a little bit more advanced that something you would be able to do with a non-custom server. Most likely. Because most server providers won’t let you execute processes, and even if, they SURELY won’t let you install GCC there and run potentially unsafe code on their machine (executing processes, remember?)…
I thought of doing something like this (online development tools with multi-language compilers, sandboxes, SVC…) someday, but just because I have a lot of space as well as a custom server right next to my normal computer.
IF you’ve got a custom server (supposing it’s Linux, and most likely LAMP):
proc_open – http://php.net/manual/en/function.proc-open.php