function beautify($inputfile, $outputfile)
{
    $settings = array('indent_width' => 2, 'indent_long_comments' => true, 'file' => $inputfile);
    $beauty = new phpBeautify($settings);
    $rs = $beauty->beautify();
    if (PEAR::isError($rs)) {
        $fp = open("php://stderr", "w");
        fputs($fp, $rs->getMessage() . "\n");
        fclose($fp);
    } else {
        $fp = fopen($outputfile, "w");
        fputs($fp, $rs, strlen($rs));
        fclose($fp);
    }
    unset($beauty);
}
/**
* Send to the browser a Form with instruction to
* beautify a php file.
*/
function enterdata()
{
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
    <html>
    <head>
    <title>Beautify PHP source code</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
<!-- 
 td, th, p {
   font-family: arial,verdana,helvetica,sans-serif;
   font-size: 9pt;
}
-->
</style>
    </head>
    <body>
    <table bgcolor="#669966" cellspacing="2" cellpadding="4" width="90%" align="center">
    <tr>
    <td bgcolor="#66cc33">
    <h1>Beautify PHP</h1>
    <h4>version
    <?php 
    echo phpBeautify::getVersion();
    ?>
    </h4>
    </td></tr>
    <tr valign="top">
    <td>
    <h4>What is <i>Beautify PHP?</i></h4>
    <p>This program tries to reformat and beautify PHP source code files automatically.
    The program is Open Source and distributed under the terms of GNU GPL.
    WARNING! It can produce unexpected output.
    Always save your work and preview the formatted code before using it.
    </p>
    </td></tr><tr><td>
    <table align="left">
    <form enctype="multipart/form-data" action="
    <?php 
    echo "http://" . getenv('SERVER_NAME') . getenv('SCRIPT_NAME');
    ?>
    " method="POST">
    <tr><td bgcolor="#66cc33" colspan="2">
    <input type="hidden" name="MAX_FILE_SIZE" value="50000">
    PHP-File to reformat:
    </td></tr><tr><td colspan="2">
    <input name="file" type="file" size="50">
    </td></tr>
    <tr><td bgcolor="#66cc33" colspan="2">Select settings of braces:</td></tr>
    <tr><td>
    <input type="radio" checked name="braces" value='<?php 
    echo BEAUT_BRACES_PEAR;
    ?>
'>Braces <a href="http://pear.php.net/manual/en/standards.php" target="_blank">PEAR</a>-style
    </td><td><input type="radio" name="braces" value='<?php 
    echo BEAUT_BRACES_C;
    ?>
'>Braces C-style
    </td></tr>
    <tr><td bgcolor="#66cc33" colspan="2">Select highlight mode:</td></tr>
    <tr><td><input type="radio" name="highlight" value=1>Highlight code
    </td><td><input type="radio" checked name="highlight" value=0>Plain text</td></tr>
    <tr><td bgcolor="#66cc33" colspan="2">Indentation:</td></tr>
    <tr><td>
    <input type="radio" name="indent_mode" checked value="s">&nbsp;Use Spaces&nbsp;<input type="text" name="indent_width" value=4 size=3 maxlength=2>
	</td></tr>
	<tr><td>
	<input type="radio" name="indent_mode" value="t">&nbsp;Use tabs
    </td></tr>
    <tr><td bgcolor="#66cc33" colspan="2">More options:</td></tr>
    <tr><td>
    <input type="checkbox" name="max" value="on">&nbsp;Max chars per line&nbsp;
    <input type="text" name="max_line" value=40 size="3" maxlength="3">
    Code will not work anymore!!! Use it for printing only
    </td></tr>
    <tr><td>
    <input type="checkbox" name="del_line" value="1">&nbsp;Delete empty lines&nbsp;
    </td></tr>
    <tr><td>
    <input type="checkbox" name="find_functions" value="1">&nbsp;List the functions as an overview at beginning of the document&nbsp;
    </td></tr>
	<tr><td bgcolor="#66cc33" colspan="2">&nbsp;</td></tr>
    <tr><td>
    <input type="submit" value="Start processing">
    </td></tr>
    </form>
    </table>
    </tr></td><tr><td>
    &copy; Copyright 2002-2003 Jens Bierkandt; more information, bug- and wishlist on: <a href="http://www.bierkandt.org/beautify">http://www.bierkandt.org/beautify</a >.
	Please help this project and <a href="http://www.bierkandt.org/beautify/donate.php">donate</a>.
    </td></tr>
    </table>
    </body>
    </html>
    <?php 
    return;
}