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

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -