prepare('SELECT sample_cases_json, expected_output FROM challenges WHERE id = ?'); $stmt->execute([$challenge_id]); $challenge = $stmt->fetch(); if ($language === 'python') { // WARNING: Executing user-submitted code with shell_exec is a major security risk. // This should be replaced with a secure sandboxed execution environment. $temp_file = tempnam(sys_get_temp_dir(), 'py'); file_put_contents($temp_file, $solution); $output = shell_exec('python3 ' . $temp_file . ' 2>&1'); unlink($temp_file); echo "
" . htmlspecialchars($output) . ""; } else { echo "