&1');
if ($configs["winHostEncoding"][3] == "true"){
$output = mb_convert_encoding($output, "UTF-8",$configs["forceEncodingType"][3]);
}
if (trim($output) == ""){
if (file_exists($binaryPath)){
if (isset($_GET['run'])){
//Run the application after compile.
$output = shell_exec($binaryPath . ' 2>&1');
if ($configs["winHostEncoding"][3] == "true"){
$output = mb_convert_encoding($output, "UTF-8",$configs["forceEncodingType"][3]);
}
echo $output;
}else{
//Compile only
echo 'Compiled succeed. Exported file: ' . $binaryPath;
}
}else{
die("Unknown Error. Compiler do not return anything.");
}
}else{
echo "Error.
" . nl2br($output);
}
} else {
//Linux, use build in gcc
$binaryPath = dirname($filepath) . "/" . basename($filepath,pathinfo($filepath, PATHINFO_EXTENSION)) . "out";
$output = shell_exec('gcc "' . $filepath .'" -o "'. $binaryPath . '" 2>&1');
if (trim($output) == ""){
if (file_exists($binaryPath)){
if (isset($_GET['run'])){
//Run the application after compile.
$output = shell_exec($binaryPath . ' 2>&1');
echo nl2br($output);
}else{
//Compile only
echo 'Compiled succeed. Exported file: ' . $binaryPath;
}
}else{
die("Unknown Error. Compiler do not return anything.");
}
}else{
echo "Error.
" . nl2br($output);
}
}
?>