Input

getenv("PATH"), "LD_LIBRARY_PATH" => getenv("LD_LIBRARY_PATH"), ); $command = "iscc"; /* PATH for iscc and all that it needs */ $env["PATH"] = "/home/aisoard/.opt/barvinok/bin:" . $env["PATH"]; $env["LD_LIBRARY_PATH"] = "/home/aisoard/.opt/barvinok/lib:" . $env["LD_LIBRARY_PATH"]; if($_POST['format'] && array_search($_POST['format'], $formats) != FALSE) $command .= " --format=" . $_POST['format']; if($_POST['indent']) { $command .= " | isl-indent"; /* PATH for isl-indent and all that it needs */ $env["PATH"] = "/home/aisoard/.opt/isl-indent/bin:" . $env["PATH"]; $env["LD_LIBRARY_PATH"] = "/home/aisoard/.opt/isl-indent/lib:" . $env["LD_LIBRARY_PATH"]; } /* Use pipes for everything. Files are bad for performance/security/parallelism, unless you want to wiretape... */ $descriptors = array( 0 => array("pipe", "r"), //stdin 1 => array("pipe", "w"), //stdout 2 => array("pipe", "w") //stderr ); $time_start = microtime(true); $process = proc_open("timeout -k 30 30 " . $command, $descriptors, $pipes, NULL, $env); if(is_resource($process)) { $input = $_POST['script']; fwrite($pipes[0], $input); fclose($pipes[0]); /* !!! DO NOT FORGET !!! */ $output = stream_get_contents($pipes[1]); fclose($pipes[1]); /* !!! DO NOT FORGET !!! */ echo "

Output

\n"; echo "
\n"; echo "
ISCC output
\n"; echo "
\n"; echo "
\n";
		echo htmlspecialchars($output);
		echo "
\n"; echo "
\n"; echo "
\n"; $error = stream_get_contents($pipes[2]); fclose($pipes[2]); /* !!! DO NOT FORGET !!! */ if($error) { echo "

Error

\n"; echo "
\n";
			echo htmlspecialchars($error);
			echo "
\n"; } $return_value = proc_close($process); /* !!! DO NOT FORGET TO CLOSE ALL PIPES BEFORE !!! */ $time_end = microtime(true); echo "

Summary

\n"; echo "
\n"; if($return_value) { echo "
Returned value
\n"; echo "
"; echo "$return_value"; if($return_value == 124 || $return_value == 128+9) echo " (timeout)"; echo "
\n"; } $time = round($time_end - $time_start, 3); echo "
Command
\n"; echo "
$command
\n"; echo "
Execution time
\n"; echo "
$time s
\n"; echo "
Version
\n"; echo "
barvinok-0.39 isl-0.16.1 polylib-5.22.5 ntl-6.2.1
\n"; if($_POST["indent"]) { echo "
Other
\n"; echo "
indented with isl-indent
\n"; } echo "
\n"; } } ?>