tags:

views:

98

answers:

1

I have this problem: I want to pass a whole C code from a php textbox onto server and want to compile it with gcc and want the output back on php page. Is it possible?

Sample code:

php page input
<textarea>
#include<stdio.h>
void main()
{
printf("hello world");
}

Compiled on server terminal/shell

php page output:

hello world
+1  A: 

Save the input as a file and call the necessary system commands on that file with the "exec()" function.

This is, however, INCREDIBLY DANGEROUS to do on a public webpage. Even if it isn't public, it's still not safe.

Aeolun
Perhaps someone wants to do it to someone else's public server, after hacking the server enough to put the necessary php page on it.
ChrisW