| Current Path : /var/www/html/venkat/check3/ |
| Current File : /var/www/html/venkat/check3/facmain.php |
<?php
$section1 = $_GET["section"];
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
$section = strstr($section1, ':', true);
$type1 = substr($section1, strrpos($section1, '.')+1);
$file1 = substr($section1, strrpos($section1, ':')+1);
$no = substr($section1, strrpos($section1, '_')+1);
$no = strstr($no,'.', true);
$uploaddir = "file/".$section."/";
$juploaddir = "file/".$section." ";
$uploadfile2 = $uploaddir.$file1;
$juploadfile2 = $juploaddir.$file1;
$upload= strstr($uploadfile2, '.', true);
$jupload= strstr($juploadfile2, '.', true);
$section12=$section.$no;
if ($type1 == "cpp") {
$w = shell_exec("g++ $uploadfile2 -o $upload.out");
}
if ($type1 == "c") {
$w = shell_exec("gcc $uploadfile2 -o $upload.out");
}
if ($type1 == "java") {
$w = shell_exec("javac $uploadfile2");
}
if ($type1 == "py") {
$w = shell_exec("timeout 0.01s python $uploadfile2 <file/$section12.txt");
}
if ($type1 == "plx") {
$w = shell_exec("timeout 0.01s perl $uploadfile2");
}
if ($type1!= "py" && $type1!= "plx" && $type1 != "java") {
$v = shell_exec("timeout 0.01s ./$upload.out < file/$section12.txt");
}
else if ($type1 == "py" || $type1 == "plx"){
$v = $w;
}
else if ($type1 == "java") {
$v = shell_exec("timeout 0.01s java -cp $jupload < file/$section12.txt");
}
//$handle = fopen($uploadfile2,"rb");
//$contents = fread($handle, filesize($uploadfile2));
//fclose($handle);
//echo $contents;
//echo "<br><pre>".htmlspecialchars(shell_exec("cat $uploadfile2"))."<pre>";
$sectionout = $section."out".$no;
$machineoutput = shell_exec("cat file/$sectionout.txt");
?>
<body bgcolor="#F0F8FF"> <center>
<h2> <font color="blue"> Program Check Window</font> </h2>
<br> <center>
<table width="100%" border="1" cellpadding="0">
<tr>
<td colspan="2"> <center> <h3> <?php echo("Program Name : ".$file1); ?> </h3> </center> </td>
</tr>
<tr>
<td colspan="2"> <?php echo ("<pre>".htmlspecialchars(shell_exec("cat $uploadfile2"))."</pre>"); ?> </td>
</tr>
<tr>
<td width = "50%"> <?php echo("<b> <center> <u> User O/P </u> </center> </b> <br> <pre>".$v."</pre>"); ?> </td>
<td width = "50%"> <?php echo("<b> <center> <u> Pre-Defined O/P </u> </center> </b> <br> <pre>".$machineoutput."</pre>"); ?> </td>
</tr>
</table> </center>
<?php
if ($type1 == "cpp" || $type1 == "c") {
shell_exec("rm $upload.out");
}
if ($type1 == "java") {
shell_exec("rm $upload.class");
}
?>