php - Web based compiler -
php - Web based compiler -
i have been working on project, create website read files(c/c++ text file) , compile code written on it.
how can utilize compiler on server?
if $_post['code'] contains cpp code. can following.
$code = do_sanitizing($_post['code']); $filename = "cfile".time().".c"; // set contents in file file_put_contents($filename, $code); // compile $output = system("/usr/bin/gcc $filename 2>&1"); echo $output; note: type of compiling , running programs afterwards has unsafe security flaws.
you must sanitize user input the c source code may crash compiling process the output programme might contain code unsafe server. php c++ html c
Comments
Post a Comment