All pastes #186302 Raw Edit

Miscellany

public text v1 · immutable
#186302 ·published 2006-09-29 19:35 UTC
rendered paste body
<?php

ob_start();

?>
<html>
    <head></head>
    <body>

        <?php

        function getPostVariable( $name ) {
            return ( isset( $_POST[ $name ] ) ? trim( urldecode( get_magic_quotes_gpc() ? stripslashes( $_POST[ $name ] ) : $_POST[ $name ] ) ) : null );
        }

        if ( empty( $_GET[ 'accepted' ] ) ) {
            if ( empty( $_POST[ 'submit' ] ) ) {
                ?>
                <form method="post">
                    Destination: <input type="text" name="destination" /><br />
                    Message: <input type="text" name="message" /><br />
                    <input type="submit" name="submit" value="  Send message  " />
                </form>
                <?php
            } else {
                $destination = getPostVariable( 'destination' );
                $message = getPostVariable( 'message' );
                system( '/path/to/application ' . escapeshellarg( $destination ) . ' ' . escapeshellarg( $message ) );
                header( 'Location: ' . $_SERVER[ 'PHP_SELF' ] . '?accepted=yes' );
                exit();
            }
        } else {
            ?>
            <p>Your message was accepted.</p>
            <?php
        }

        ?>

    </body>
</html>
<?php

$output = ob_get_contents();
ob_end_clean();

echo $output;

?>