<?php

$postData = file_get_contents("php://input");

$uid = $postData['id'];
$filename = $postData['filename'];
$language = $postData['language'];

$ret_stat = 0;

if(strcmp($language, "cpp") == 0)
{
    $base = basename($filename, ".cpp");
    system("g++ " . $uid . "/" . $filename . " -o " . $uid . "/" . $base , $ret_stat);

    if($ret_stat != 0)
    {
        unlink($uid . "/" . $base);
    }
}

else if(strcmp($language, "java") == 0)
{
    $base = basename($filename, ".java");
    system("javac " . $uid . "/" . $filename , $ret_stat);

    if($ret_stat != 0)
    {
        unlink($uid . "/" . $base . ".class");
    }
}

echo $ret_stat;
?>