0

我正在尝试使用 php 执行输入到文本字段中的终端命令。我试图让它使用来自各处的代码来工作。如果您能看到我哪里出错了,我将非常感谢您的帮助...

            <?php
        function doSomething() { 
            echo 'Guess this is working'; 
            exec($command . '2>&1', $output, $return);
            echo "Dir returned $return, and output:\n";
            } 
        if(count($_POST) > 0 && isset($_POST['command'])) \
            { 
            doSomething(); 
            } 
        ?>
        <!DOCTYPE html>

        <html>
        <head>
            <meta content="text/html; charset=utf-8" http-equiv="Content-Type">

            <title>Terminal Emulator</title>
        </head>

        <body>
            <form action="%3C?php%20echo%20$_SERVER['PHP_SELF'];%20?%3E" method="post">
                <input autocomplete="off" id="command" name="command" type="text">
                <input type="submit" value="Submit">
            </form>
        </body>
        </html>
4

1 回答 1

0
<?php
        function doSomething($command) { 
            echo 'Guess this is working'; 
            exec($command . '2>&1', $output, $return);
            echo "Dir returned $return, and output:\n";
            } 
        if(count($_POST) > 0 && isset($_POST['command'])) \
            { 
            doSomething($_POST['command']); 
            } 
        ?>
        <!DOCTYPE html>

        <html>
        <head>
            <meta content="text/html; charset=utf-8" http-equiv="Content-Type">

            <title>Terminal Emulator</title>
        </head>

        <body>
            <form action="%3C?php%20echo%20$_SERVER['PHP_SELF'];%20?%3E" method="post">
                <input autocomplete="off" id="command" name="command" type="text">
                <input type="submit" value="Submit">
            </form>
        </body>
        </html>

// $输出在哪里

于 2013-08-20T11:17:46.873 回答