Last active
August 29, 2015 14:27
-
-
Save ucguy4u/159bdb346425be2db7cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$CC="gcc"; | |
$out="a"; | |
$code=$_POST["code"]; | |
$input=$_POST["input"]; | |
$filename_code="main.c"; | |
$filename_in="input.txt"; | |
$filename_error="error.txt"; | |
$executable="a"; | |
$command=$CC." -lm ".$filename_code; | |
$command_error=$command." 2>".$filename_error; | |
//if(trim($code)=="") | |
//die("The code area is empty"); | |
$file_code=fopen($filename_code,"w+"); | |
fwrite($file_code,$code); | |
fclose($file_code); | |
$file_in=fopen($filename_in,"w+"); | |
fwrite($file_in,$input); | |
fclose($file_in); | |
exec("chmod 777 $executable"); | |
exec("chmod 777 $filename_error"); | |
shell_exec($command_error); | |
$error=file_get_contents($filename_error); | |
if(trim($error)=="") | |
{ | |
if(trim($input)=="") | |
{ | |
$output=shell_exec($out); | |
} | |
else | |
{ | |
$out=$out." < ".$filename_in; | |
$output=shell_exec($out); | |
} | |
echo "<pre>$output</pre>"; | |
} | |
else if(!strpos($error,"error")) | |
{ | |
echo "<pre>$error</pre>"; | |
if(trim($input)=="") | |
{ | |
$output=shell_exec($out); | |
} | |
else | |
{ | |
$out=$out." < ".$filename_in; | |
$output=shell_exec($out); | |
} | |
echo "<pre>$output</pre>"; | |
} | |
else | |
{ | |
echo "<pre>$error</pre>"; | |
} | |
exec("rm $filename_code"); | |
exec("rm *.o"); | |
exec("rm *.txt"); | |
exec("rm $executable"); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$languageID=$_POST["language"]; | |
switch($languageID) | |
{ | |
case "c": | |
{ | |
include("../c.php"); | |
break; | |
} | |
case "cpp": | |
{ | |
include("../cpp.php"); | |
break; | |
} | |
case "java": | |
{ | |
include("../java.php"); | |
break; | |
} | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$CC="g++"; | |
$out="a"; | |
$code=$_POST["code"]; | |
$input=$_POST["input"]; | |
$filename_code="main.cpp"; | |
$filename_in="input.txt"; | |
$filename_error="error.txt"; | |
$executable="a"; | |
$command=$CC." -lm ".$filename_code; | |
$command_error=$command." 2>".$filename_error; | |
//if(trim($code)=="") | |
//die("The code area is empty"); | |
$file_code=fopen($filename_code,"w+"); | |
fwrite($file_code,$code); | |
fclose($file_code); | |
$file_in=fopen($filename_in,"w+"); | |
fwrite($file_in,$input); | |
fclose($file_in); | |
exec("chmod 777 $executable"); | |
exec("chmod 777 $filename_error"); | |
shell_exec($command_error); | |
$error=file_get_contents($filename_error); | |
if(trim($error)=="") | |
{ | |
if(trim($input)=="") | |
{ | |
$output=shell_exec($out); | |
} | |
else | |
{ | |
$out=$out." < ".$filename_in; | |
$output=shell_exec($out); | |
} | |
echo "<pre>$output</pre>"; | |
} | |
else if(!strpos($error,"error")) | |
{ | |
echo "<pre>$error</pre>"; | |
if(trim($input)=="") | |
{ | |
$output=shell_exec($out); | |
} | |
else | |
{ | |
$out=$out." < ".$filename_in; | |
$output=shell_exec($out); | |
} | |
echo "<pre>$output</pre>"; | |
} | |
else | |
{ | |
echo "<pre>$error</pre>"; | |
} | |
exec("rm $filename_code"); | |
exec("rm *.o"); | |
exec("rm *.txt"); | |
exec("rm $executable"); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
?> | |
<html> | |
<head> | |
<title>Online Compiler for Off-Campus Students</title> | |
</head> | |
<body> | |
<div id="whole"> | |
<div id="content"> | |
<table class="code"> | |
<td class="code"> | |
<form action="compile.php" method="post" id="form"> | |
Select Language of Interest: | |
<select name="language" id="language"> | |
<option value="c">C</option> | |
<option value="cpp">C++</option> | |
<option value="java">Java</option> | |
</select> | |
<br /> | |
<strong>Enter Your code here:<br/></strong> | |
<textarea name="code" rows=15 cols=100 onkeydown=insertTab(this,event) id="code"></textarea><br/> | |
<span id="errorCode" class="error"></span><br/><br/> | |
<strong>Sample Input please:<br/></strong> | |
<textarea name="input" rows=7 cols=100 id="input"></textarea><br/><br/> | |
<input type="submit" value="Submit" id="submit"> | |
<input type="reset" value="Reset"><br/> | |
</form> | |
</td> | |
</div> | |
</div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$CC="javac"; | |
$out="java main"; | |
$code=$_POST["code"]; | |
$input=$_POST["input"]; | |
$filename_code="main.java"; | |
$filename_in="input.txt"; | |
$filename_error="error.txt"; | |
$runtime_file="runtime.txt"; | |
$executable="*.class"; | |
$command=$CC." ".$filename_code; | |
$command_error=$command." 2>".$filename_error; | |
$runtime_error_command=$out." 2>".$runtime_file; | |
//if(trim($code)=="") | |
//die("The code area is empty"); | |
$file_code=fopen($filename_code,"w+"); | |
fwrite($file_code,$code); | |
fclose($file_code); | |
$file_in=fopen($filename_in,"w+"); | |
fwrite($file_in,$input); | |
fclose($file_in); | |
exec("chmod 777 $executable"); | |
exec("chmod 777 $filename_error"); | |
shell_exec($command_error); | |
$error=file_get_contents($filename_error); | |
if(trim($error)=="") | |
{ | |
if(trim($input)=="") | |
{ | |
shell_exec($runtime_error_command); | |
$runtime_error=file_get_contents($runtime_file); | |
$output=shell_exec($out); | |
} | |
else | |
{ | |
shell_exec($runtime_error_command); | |
$runtime_error=file_get_contents($runtime_file); | |
$out=$out." < ".$filename_in; | |
$output=shell_exec($out); | |
} | |
echo "<pre>$runtime_error</pre>"; | |
echo "<pre>$output</pre>"; | |
} | |
else if(!strpos($error,"error")) | |
{ | |
echo "<pre>$error</pre>"; | |
if(trim($input)=="") | |
{ | |
$output=shell_exec($out); | |
} | |
else | |
{ | |
$out=$out." < ".$filename_in; | |
$output=shell_exec($out); | |
} | |
echo "<pre>$output</pre>"; | |
} | |
else | |
{ | |
echo "<pre>$error</pre>"; | |
} | |
exec("rm $filename_code"); | |
exec("rm *.txt"); | |
exec("rm $executable"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment