function create_instance_from_path($program_path) { global $conf_max_instances; // Find unused instance ID do { $instance = rand(0, $conf_max_instances); $path = instance_path($instance); } while (file_exists($path)); directoryCleanup($path); `cp -R {$program_path}/* {$path}`; return $instance; }
function create_instance($zip_file) { global $conf_max_instances, $conf_unzip_command, $conf_verbosity; // Find unused instance ID do { $instance = rand(0, $conf_max_instances); $path = instance_path($instance); } while (file_exists($path)); directoryCleanup($path); if ($conf_verbosity > 0) { print "Unzipping file...\n"; } $output = `{$conf_unzip_command} "{$zip_file}" -d {$path}`; if ($conf_verbosity > 2) { print $output; } return $instance; }
$result['success'] = "false"; $result['code'] = "ERR003"; $result["message"] = "Access denied"; } else { $filename = $r[1]; $jezik = $r[3]; $predmet = $r[4]; $ag = $r[5]; $komp_opc = $r[6]; $komp_opc_debug = $r[7]; $filepath = "{$conf_files_path}/zadace/{$predmet}-{$ag}/{$student}/{$zadaca}/{$filename}"; // Učitavamo sve fajlove radi ispisa linije u kojoj je greška $nalaz = ""; $sources = array(); if (ends_with($filename, ".zip")) { directoryCleanup($autotest_basepath); $output = `unzip "{$filepath}" -d {$autotest_basepath}`; $filelist = array(); foreach ($conf_extensions[$jezik] as $ekst) { $k = exec("find {$autotest_basepath} -name \\*{$ekst}", $blah, $return); $filelist = array_unique(array_merge($filelist, $blah)); } if ($filelist === array()) { $result['success'] = "false"; $result['code'] = "ERR006"; $result["message"] = "Failed to unzip"; print json_encode($result); dbdisconnect(); exit; } foreach ($filelist as $filename) {