Obfuscating PHP Code

Semantic Designs can construct custom obfuscators for virtually any source language as a part of the corresponding Source Formatter. This page contains PHP sample code, its obfuscated version, and the generated obfuscation map.

PHP Sample Code before Obfuscation

What follows is an open-source, simple PHP4 loan calculator program. (You can download the actual source and run it on your PHP server if you like. Don't copy the text below; it has been HTMLized.) Notice the copyright at the end.


<?php
    /*
        PHP Mortgage Calculator
        version: 1.1
        last update: Jan 1, 2003
        ----------------------------------------------------
        The PHP Mortgage Calculator tries to figure out a home 
        owners mortgage payments, and the breakdown of each monthly
        payment.
        
        The calculator accepts:
            Price (cost of home in US Dollars)
            Percentage of Down Payment
            Length of Mortgage
            Annual Interest Rate
        
        Based on the four items that the user enters, we can figure
        out the down payment (in US Dollars), the ammount that the 
        buyer needs to finance, and the monthly finance payment. 
        The calculator can also break down the monthly payments 
        so we know how much goes towards the mortgage's interest, 
        the mortgage's principal, the loan's Private Mortgage Insurance 
        (if less that 20% was used as a down payment), and an rough 
        estimate of the property's residential tax
        
        [ See below for LICENSE ]
    */
    
    /* --------------------------------------------------- *
     * Set Form DEFAULT values
     * --------------------------------------------------- */
    $default_sale_price              = "150000";
    $default_annual_interest_percent = 7.0;
    $default_year_term               = 30;
    $default_down_percent            = 10;
    $default_show_progress           = TRUE;
    /* --------------------------------------------------- */
    


    /* --------------------------------------------------- *
     * Initialize Variables
     * --------------------------------------------------- */
    $sale_price                      = 0;
    $annual_interest_percent         = 0;
    $year_term                       = 0;
    $down_percent                    = 0;
    $this_year_interest_paid         = 0;
    $this_year_principal_paid        = 0;
    $form_complete                   = false;
    $show_progress                   = false;
    $monthly_payment                 = false;
    $show_progress                   = false;
    $error                           = false;
    /* --------------------------------------------------- */


    /* --------------------------------------------------- *
     * Set the USER INPUT values
     * --------------------------------------------------- */
    if (isset($_REQUEST['form_complete'])) {
        $sale_price                      = $_REQUEST['sale_price'];
        $annual_interest_percent         = $_REQUEST['annual_interest_percent'];
        $year_term                       = $_REQUEST['year_term'];
        $down_percent                    = $_REQUEST['down_percent'];
        $show_progress                   = (isset($_REQUEST['show_progress'])) ? $_REQUEST['show_progress'] : false;
        $form_complete                   = $_REQUEST['form_complete'];
    }
    /* --------------------------------------------------- */
    
    
    // If HTML headers have not already been sent, we'll print some here    
    if (!headers_sent()) {
        print("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><HTML>");
        print("<head><title>Mortgage Calculator</title></HEAD><BODY>");
        print("<body bgcolor=\'#33ccff\'>");
        print("<H1 style=\'margin-bottom: 35px;\'>PHP Mortgage Calculator</h1>");
        print("<hr>\n\n");
        $print_footer = TRUE;
    } else {
       $print_footer = FALSE;
    }
    
    // Style Sheet
    ?>
    <style type="text/css">
        <!--
            td {
                font-size : 11px; 
                font-family : tahoma, helvetica, arial, lucidia, sans-serif; 
                color : #000000; 
            }
        -->
    </style> 


    <?php    
    /* --------------------------------------------------- */
    // This function does the actual mortgage calculations
    // by plotting a PVIFA (Present Value Interest Factor of Annuity)
    // table...
    function get_interest_factor($year_term, $monthly_interest_rate) {
        global $base_rate;
        
        $factor      = 0;
        $base_rate   = 1 + $monthly_interest_rate;
        $denominator = $base_rate;
        for ($i=0; $i < ($year_term * 12); $i++) {
            $factor += (1 / $denominator);
            $denominator *= $base_rate;
        }
        return $factor;
    }        
    /* --------------------------------------------------- */

    // If the form is complete, we'll start the math
    if ($form_complete) {
        // We'll set all the numeric values to JUST
        // numbers - this will delete any dollars signs,
        // commas, spaces, and letters, without invalidating
        // the value of the number
        $sale_price              = ereg_replace( "[^0-9.]", "", $sale_price);
        $annual_interest_percent = eregi_replace("[^0-9.]", "", $annual_interest_percent);
        $year_term               = eregi_replace("[^0-9.]", "", $year_term);
        $down_percent            = eregi_replace("[^0-9.]", "", $down_percent);
        
        if (((float) $year_term <= 0) || ((float) $sale_price <= 0) || ((float) $annual_interest_percent <= 0)) {
            $error = "You must enter a <b>Sale Price of Home</b>, <b>Length of Motgage</b> <i>and</i> <b>Annual Interest Rate</b>";
        }
        
        if (!$error) {
            $month_term              = $year_term * 12;
            $down_payment            = $sale_price * ($down_percent / 100);
            $annual_interest_rate    = $annual_interest_percent / 100;
            $monthly_interest_rate   = $annual_interest_rate / 12;
            $financing_price         = $sale_price - $down_payment;
            $monthly_factor          = get_interest_factor($year_term, $monthly_interest_rate);
            $monthly_payment         = $financing_price / $monthly_factor;
        }
    } else {
        if (!$sale_price)              { $sale_price              = $default_sale_price;              }
        if (!$annual_interest_percent) { $annual_interest_percent = $default_annual_interest_percent; }
        if (!$year_term)               { $year_term               = $default_year_term;               }
        if (!$down_percent)            { $down_percent            = $default_down_percent;            }
        if (!$show_progress)           { $show_progress           = $default_show_progress;           }
    }
    
    if ($error) {
        print("<font color=\"red\">" . $error . "</font><br><br>\n");
        $form_complete   = false;
    }
?>
<font size="-1" color="#000000">This <b>mortgage calculator</b> can be used to figure out monthly payments of a home mortgage loan, based on the home's sale price, the term of the loan desired, buyer's down payment percentage, and the loan's interest rate. This calculator factors in PMI (Private Mortgage Insurance) for loans where less than 20% is put as a down payment. Also taken into consideration are the town property taxes, and their effect on the total monthly mortgage payment.<br></font>

<form method="GET" name="information" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="form_complete" value="1">
<table cellpadding="2" cellspacing="0" border="0" width="100%">
    <tr valign="top">
        <td align="right"><img src="/images/clear.gif" width="225" height="1" border="0" alt=""></td>
        <td align="smalltext" width="100%"><img src="/images/clear.gif" width="250" height="1" border="0" alt=""></td>
    </tr>
    <tr valign="top" bgcolor="#cccccc">
        <td align="center" colspan="2"><b>Purchase &amp; Financing Information</b></td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
        <td align="right">Sale Price of Home:</td>
        <td width="100%"><input type="text" size="10" name="sale_price" value="<?php echo $sale_price; ?>">(In Dollars)</td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
        <td align="right">Percentage Down:</td>
        <td><input type="text" size="5" name="down_percent" value="<?php echo $down_percent; ?>">%</td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
        <td align="right">Length of Mortgage:</td>
        <td><input type="text" size="3" name="year_term" value="<?php echo $year_term; ?>">years</td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
        <td align="right">Annual Interest Rate:</td>
        <td><input type="text" size="5" name="annual_interest_percent" value="<?php echo $annual_interest_percent; ?>">%</td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
        <td align="right">Explain Calculations:</td>
        <td><input type="checkbox" name="show_progress" value="1" <?php if ($show_progress) { print("checked"); } ?>> Show me the calculations and amortization</td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
        <td>&nbsp;</td>
        <td><input type="submit" value="Calculate"><br><?php if ($form_complete) { print("<a href=\"" . $_SERVER['PHP_SELF'] . "\">Start Over</a><br>"); } ?><br></td>
    </tr>
<?php
    // If the form has already been calculated, the $down_payment
    // and $monthly_payment variables will be figured out, so we
    // can show them in this table
    if ($form_complete && $monthly_payment) {
?>
        <tr valign="top">
            <td align="center" colspan="2" bgcolor="#000000"><font color="#ffffff"><b>Mortgage Payment Information</b></font></td>
        </tr>
        <tr valign="top" bgcolor="#eeeeee">
            <td align="right">Down Payment:</td>
            <td><b><?php echo "\$" . number_format($down_payment, "2", ".", "thousands_sep"); ?></b></td>
        </tr>
        <tr valign="top" bgcolor="#eeeeee">
            <td align="right">Amount Financed:</td>
            <td><b><?php echo "\$" . number_format($financing_price, "2", ".", "thousands_sep"); ?></b></td>
        </tr>
        <tr valign="top" bgcolor="#cccccc">
            <td align="right">Monthly Payment:</td>
            <td><b><?php echo "\$" . number_format($monthly_payment, "2", ".", "thousands_sep"); ?></b><br><font>(Principal &amp; Interest ONLY)</font></td>
        </tr>
        <?php
            if ($down_percent >= 20)
               $pmi_per_month=0; // no PMI
            else {
                $pmi_per_month = 55 * ($financing_price / 100000);
        ?>
                <tr valign="top" bgcolor="#FFFFCC">
                    <td align="right">&nbsp;</td>
                    <td>
                        <br>
                        Since you are putting LESS than 20% down, you will need to pay PMI (<a href="http://www.google.com/search?hl=en&q=private+mortgage+insurance">Private Mortgage Insurance</a>), which tends to be about $55 per month for every $100,000 financed (until you have paid off 20% of your loan). This could add <?php echo "\$" . number_format($pmi_per_month, "2", ".", "thousands_sep"); ?> to your monthly payment.
                    </td>
                </tr>
                <tr valign="top" bgcolor="#FFFF99">
                    <td align="right">Monthly Payment:</td>
                    <td><b><?php echo "\$" . number_format(($monthly_payment + $pmi_per_month), "2", ".", "thousands_sep"); ?></b><br><font>(Principal &amp; Interest, and PMI)</td>
                </tr>
        <?php
            }
        ?>
        <tr valign="top" bgcolor="#CCCCFF">
            <td align="right">&nbsp;</td>
            <td>
                <br>
                <?php
                    $assessed_price          = ($sale_price * .85);
                    $residential_yearly_tax  = ($assessed_price / 1000) * 14;
                    $residential_monthly_tax = $residential_yearly_tax / 12;
                    
                    if ($pmi_per_month == 0)
                        $pmi_text = "";
                    else {
                        $pmi_text = "PMI and ";
                    }
                ?>
                Residential (or Property) Taxes are a little harder to figure out... In Massachusetts, the average resedential tax rate seems to be around $14 per year for every $1,000 of your property's assessed value.
                <br><br>
                Let's say that your property's <i>assessed value</i> is 85% of what you actually paid for it - <?php echo "\$" . number_format($assessed_price, "2", ".", "thousands_sep"); ?>. This would mean that your yearly residential taxes will be around <?php echo "\$" . number_format($residential_yearly_tax, "2", ".", "thousands_sep"); ?>
                This could add <?php echo "\$" . number_format($residential_monthly_tax, "2", ".", "thousands_sep"); ?> to your monthly payment.
            </td>
        </tr>
        <tr valign="top" bgcolor="#9999FF">
            <td align="right">TOTAL Monthly Payment:</td>
            <td><b><?php echo "\$" . number_format(($monthly_payment + $pmi_per_month + $residential_monthly_tax), "2", ".", "thousands_sep"); ?></b><br><font>(including <?php echo $pmi_text; ?> residential tax)</font></td>
        </tr>
<?php    
    }
?>
</table>
</form>
<?php
    // This prints the calculation progress and 
    // the instructions of HOW everything is figured
    // out
    if ($form_complete && $show_progress) {
        $step = 1;
?>
        <br><br>
        <table cellpadding="5" cellspacing="0" border="1" width="100%">
            <tr valign="top">
                <td><b><?php echo $step++; ?></b></td>
                <td>
                    The <b>down payment</b> = The price of the home multiplied by the percentage down divided by 100 (for 5% down becomes 5/100 or 0.05)<br><br>
                    $<?php echo number_format($down_payment,"2",".","thousands_sep"); ?> = $<?php echo number_format($sale_price,"2",".","thousands_sep"); ?> X (<?php echo $down_percent; ?> / 100)
                </td>
            </tr>
            <tr valign="top">
                <td><b><?php echo $step++; ?></b></td>
                <td>
                    The <b>interest rate</b> = The annual interest percentage divided by 100<br><br>
                    <?php echo $annual_interest_rate; ?> = <?php echo $annual_interest_percent; ?>% / 100
                </td>
            </tr>
            <tr valign="top" bgcolor="#cccccc">
                <td colspan="2">
                    The <b>monthly factor</b> = The result of the following formula:
                </td>
            </tr>
            <tr valign="top">
                <td><b><?php echo $step++; ?></b></td>
                <td>
                    The <b>monthly interest rate</b> = The annual interest rate divided by 12 (for the 12 months in a year)<br><br>
                    <?php echo $monthly_interest_rate; ?> = <?php echo $annual_interest_rate; ?> / 12
                </td>
            </tr>
            <tr valign="top">
                <td><b><?php echo $step++; ?></b></td>
                <td>
                    The <b>month term</b> of the loan in months = The number of years you've taken the loan out for times 12<br><br>
                    <?php echo $month_term; ?> Months = <?php echo $year_term; ?> Years X 12
                </td>
            </tr>
            <tr valign="top">
                <td><b><?php echo $step++; ?></b></td>
                <td>
                    The montly payment is figured out using the following formula:<br>
                    Monthly Payment = <?php echo number_format($financing_price, "2", "", ""); ?> * (<?php echo number_format($monthly_interest_rate, "4", "", ""); ?> / (1 - ((1 + <?php echo number_format($monthly_interest_rate, "4", "", ""); ?>)<sup>-(<?php echo $month_term; ?>)</sup>)))
                    <br><br>
                    The <a href="#amortization">amortization</a> breaks down how much of your monthly payment goes towards the bank's interest, and how much goes into paying off the principal of your loan.
                </td>
            </tr>
        </table>
        <br>
<?php
        // Set some base variables
        $principal     = $financing_price;
        $current_month = 1;
        $current_year  = 1;
        // This basically, re-figures out the monthly payment, again.
        $power = -($month_term);
        $denom = pow((1 + $monthly_interest_rate), $power);
        $monthly_payment = $principal * ($monthly_interest_rate / (1 - $denom));
        
        print("<br><br><a name=\"amortization\"></a>Amortization For Monthly Payment: <b>\$" . number_format($monthly_payment, "2", ".", "thousands_sep") . "</b> over " . $year_term . " years<br>\n");
        print("<table cellpadding=\"5\" cellspacing=\"0\" bgcolor=\"#eeeeee\" border=\"1\" width=\"100%\">\n");
        
        // This LEGEND will get reprinted every 12 months
        $legend  = "\t<tr valign=\"top\" bgcolor=\"#cccccc\">\n";
        $legend .= "\t\t<td align=\"right\"><b>Month</b></td>\n";
        $legend .= "\t\t<td align=\"right\"><b>Interest Paid</b></td>\n";
        $legend .= "\t\t<td align=\"right\"><b>Principal Paid</b></td>\n";
        $legend .= "\t\t<td align=\"right\"><b>Remaing Balance</b></td>\n";
        $legend .= "\t</tr>\n";
        
        echo $legend;
                
        // Loop through and get the current month's payments for 
        // the length of the loan 
        while ($current_month <= $month_term) {        
            $interest_paid     = $principal * $monthly_interest_rate;
            $principal_paid    = $monthly_payment - $interest_paid;
            $remaining_balance = $principal - $principal_paid;
            
            $this_year_interest_paid  = $this_year_interest_paid + $interest_paid;
            $this_year_principal_paid = $this_year_principal_paid + $principal_paid;
            
            print("\t<tr valign=\"top\" bgcolor=\"#eeeeee\">\n");
            print("\t\t<td align=\"right\">" . $current_month . "</td>\n");
            print("\t\t<td align=\"right\">\$" . number_format($interest_paid, "2", ".", "thousands_sep") . "</td>\n");
            print("\t\t<td align=\"right\">\$" . number_format($principal_paid, "2", ".", "thousands_sep") . "</td>\n");
            print("\t\t<td align=\"right\">\$" . number_format($remaining_balance, "2", ".", "thousands_sep") . "</td>\n");
            print("\t</tr>\n");
    
            ($current_month % 12) ? $show_legend = FALSE : $show_legend = TRUE;
    
            if ($show_legend) {
                print("\t<tr valign=\"top\" bgcolor=\"#ffffcc\">\n");
                print("\t\t<td colspan=\"4\"><b>Totals for year " . $current_year . "</td>\n");
                print("\t</tr>\n");
                
                $total_spent_this_year = $this_year_interest_paid + $this_year_principal_paid;
                print("\t<tr valign=\"top\" bgcolor=\"#ffffcc\">\n");
                print("\t\t<td>&nbsp;</td>\n");
                print("\t\t<td colspan=\"3\">\n");
                print("\t\t\tYou will spend \$" . number_format($total_spent_this_year, "2", ".", "thousands_sep") . " on your house in year " . $current_year . "<br>\n");
                print("\t\t\t\$" . number_format($this_year_interest_paid, "2", ".", "thousands_sep") . " will go towards INTEREST<br>\n");
                print("\t\t\t\$" . number_format($this_year_principal_paid, "2", ".", "thousands_sep") . " will go towards PRINCIPAL<br>\n");
                print("\t\t</td>\n");
                print("\t</tr>\n");
    
                print("\t<tr valign=\"top\" bgcolor=\"#ffffff\">\n");
                print("\t\t<td colspan=\"4\">&nbsp;<br><br></td>\n");
                print("\t</tr>\n");
                
                $current_year++;
                $this_year_interest_paid  = 0;
                $this_year_principal_paid = 0;
                
                if (($current_month + 6) < $month_term) {
                    echo $legend;
                }
            }
    
            $principal = $remaining_balance;
            $current_month++;
        }
        print("</table>\n");
    }
?>
<br>

<!-- END BODY -->


<?php
    if ($print_footer) {
        print("</body>\n");
        print("</BODY>
</HTML>\n");
    }

?>

<?php
/*
    ///// mortgage_calculator.php /////
    Copyright (c) 2002 David Tufts <http://dave.imarc.net> 
    All rights reserved.
    
    Redistribution and use in source and binary forms, with or without 
    modification, are permitted provided that the following conditions 
    are met:
    
    *    Redistributions of source code must retain the above copyright 
     notice, this list of conditions and the following disclaimer.
    *    Redistributions in binary form must reproduce the above 
     copyright notice, this list of conditions and the following 
     disclaimer in the documentation and/or other materials 
     provided with the distribution.
    *    Neither the name of David Tufts nor the names of its 
     contributors may be used to endorse or promote products 
     derived from this software without specific prior 
     written permission.
    
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
    CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
    BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
    TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
    ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
    OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
    POSSIBILITY OF SUCH DAMAGE.
*/
?> 

PHP Code after Obfuscation

You can download and see the actual text of the obfuscated version; don't expect to see much of the program code, because all the comments and linebreaks are gone. The obfuscator doesn't really touch the HTML, because it will get sent to the browser anyway where it can be seen with "View Source". Notice the obfuscator automatically preserved the copyright message. You can save the actual obfuscated version and run it on your PHP server; it should behave identically to the unobfuscated version above. This form should be pretty discouraging to the would-be thief.

Because the obfuscated version is so difficult to read, we've reproduced it again below, simply inserting linebreaks after every semicolon, so you have a chance to see what the obfuscator has done to the program variables and strings. Notice that comments are gone, names have been scrambled, text strings obscured. Larger constants have their radix twiddled. The obfuscator uses a special list provided by the user to define names that should be preserved, ensuring that public interfaces and accesses to public libraries remain valid. If you obfuscate a set of PHP source files simultaneously, only the public symbols they collectively offer will be visible in the compiled source files. Granted, a thief can insert these line breaks too, but you can see for yourself what he'll get; it is still pretty discouraging. Don't copy the text below; it has been HTMLized.


<?php $l1b0="\061\065\06000\060";
 $O1b0=.70e1;
 $l1b1=036;
 $O1b1=012;
 $l1b2=TRUE;
 $O1b2=0;
 $l1b3=0;
 $O1b3=0;
 $l1b4=0;
 $O1b4=0;
 $l1b5=0;
 $O1b5=FALSE;
 $l1b6=FALSE;
 $O1b6=FALSE;
 $l1b6=FALSE;
 $l1b7=FALSE;
 if ( isset ($_REQUEST['form_complete'])) { $O1b2=$_REQUEST['sale_price'];
 $l1b3=$_REQUEST['annual_interest_percent'];
 $O1b3=$_REQUEST['year_term'];
 $l1b4=$_REQUEST['down_percent'];
 $l1b6=( isset ($_REQUEST['show_progress'])) ? $_REQUEST['show_progress']: FALSE;
 $O1b5=$_REQUEST['form_complete'];
 } if (!headers_sent()) { print ("\074\041D\117\103\124\131P\105 \110TML PU\102LI\103 '\055\057/\1273\103//\104\124D\040H\124\115\114 \064.0\061 \124\162\141n\163it\151\157na\154/\057EN\047\076<H\124\115L\076");
 print ("\074\150\145a\144><title>\115ortgag\145 C\141lcul\141tor\074/t\151\164\154\145></\110E\101D><BO\104\131>");
 print ("\074\142\157dy\040bgcolor=\134'\043\063\063\143cff\134\047>");
 print ("\074\1101\040st\171\154e=\134\047mar\147in-bottom:\040\0635p\170;\134'\076\120\110\120 Mortgage \103al\143u\154at\157r<\057h1\076");
 print ("<h\162\076\n\n");
 $O1b7=TRUE;
 } else { $O1b7=FALSE;
 } ?>
    <style type="text/css">
        <!--
            td {
                font-size : 11px; 
                font-family : tahoma, helvetica, arial, lucidia, sans-serif; 
                color : #000000; 
            }
        -->
    </style> 


    <?php function l1b8($O1b3,$O1b8) { global $l1b9;
 $O1b9=0;
 $l1b9=1+$O1b8;
 $l1ba=$l1b9;
 for ($O1ba=0;
 $O1ba<($O1b3*014);
 $O1ba ++) { $O1b9 += (1/$l1ba);
 $l1ba *= $l1b9;
 } return $O1b9;
 } if ($O1b5) { $O1b2=ereg_replace("\133\136\060-\071\056\135","",$O1b2);
 $l1b3=eregi_replace("[\136\060\0559\056]","",$l1b3);
 $O1b3=eregi_replace("[^0\055\071\056]","",$O1b3);
 $l1b4=eregi_replace("[\136\060-\071\056]","",$l1b4);
 if (( (double) $O1b3<=0) || ( (double) $O1b2<=0) || ( (double) $l1b3<=0)) { $l1b7="Y\157u\040m\165\163\164 en\164er a\040\074\142\076\123a\154e\040P\162i\143\145 o\146 H\157me\074/b\076,\040<\142\076L\145\156g\164\150 \157f \115o\164\147age</b\076 <i\076\141\156\144</i> <b>An\156ual Interest R\141te<\057\142>";
 } if (!$l1b7) { $l1bb=$O1b3*014;
 $O1bb=$O1b2*($l1b4/0144);
 $l1bc=$l1b3/0144;
 $O1b8=$l1bc/014;
 $O1bc=$O1b2-$O1bb;
 $l1bd=l1b8($O1b3,$O1b8);
 $O1b6=$O1bc/$l1bd;
 } } else { if (!$O1b2) { $O1b2=$l1b0;
 } if (!$l1b3) { $l1b3=$O1b0;
 } if (!$O1b3) { $O1b3=$l1b1;
 } if (!$l1b4) { $l1b4=$O1b1;
 } if (!$l1b6) { $l1b6=$l1b2;
 } } if ($l1b7) { print ("\074fon\164\040color=\042r\145d\042>".$l1b7."<\057\146o\156\164\076<\142r>\074\142\162>\n");
 $O1b5=FALSE;
 } ?>
<font size="-1" color="#000000">This <b>mortgage calculator</b> can be used to figure out monthly payments of a home mortgage loan, based on the home's sale price, the term of the loan desired, buyer's down payment percentage, and the loan's interest rate. This calculator factors in PMI (Private Mortgage Insurance) for loans where less than 20% is put as a down payment. Also taken into consideration are the town property taxes, and their effect on the total monthly mortgage payment.<br></font>

<form method="GET" name="information" action="<?php echo $_SERVER['PHP_SELF'];
 ?>">
<input type="hidden" name="form_complete" value="1">
<table cellpadding="2" cellspacing="0" border="0" width="100%">
    <tr valign="top">
        <td align="right"><img src="/images/clear.gif" width="225" height="1" border="0" alt=""></td>
        <td align="smalltext" width="100%"><img src="/images/clear.gif" width="250" height="1" border="0" alt=""></td>
    </tr>
    <tr valign="top" bgcolor="#cccccc">
        <td align="center" colspan="2"><b>Purchase &amp; Financing Information</b></td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
        <td align="right">Sale Price of Home:</td>
        <td width="100%"><input type="text" size="10" name="sale_price" value="<?php echo $O1b2;
 ?>">(In Dollars)</td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
        <td align="right">Percentage Down:</td>
        <td><input type="text" size="5" name="down_percent" value="<?php echo $l1b4;
 ?>">%</td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
        <td align="right">Length of Mortgage:</td>
        <td><input type="text" size="3" name="year_term" value="<?php echo $O1b3;
 ?>">years</td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
        <td align="right">Annual Interest Rate:</td>
        <td><input type="text" size="5" name="annual_interest_percent" value="<?php echo $l1b3;
 ?>">%</td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
        <td align="right">Explain Calculations:</td>
        <td><input type="checkbox" name="show_progress" value="1" <?php if ($l1b6) { print ("ch\145\143k\145\144");
 } ?>> Show me the calculations and amortization</td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
        <td>&nbsp;</td>
        <td><input type="submit" value="Calculate"><br><?php if ($O1b5) { print ("<a \150\162e\146\075\042".$_SERVER['PHP_SELF']."\042>\123\164\141r\164 Ove\162<\057a\076\074\142r\076");
 } ?><br></td>
    </tr>
<?php if ($O1b5 && $O1b6) {;
 ?>
        <tr valign="top">
            <td align="center" colspan="2" bgcolor="#000000"><font color="#ffffff"><b>Mortgage Payment Information</b></font></td>
        </tr>
        <tr valign="top" bgcolor="#eeeeee">
            <td align="right">Down Payment:</td>
            <td><b><?php echo "\044".number_format($O1bb,"\062",".","th\157u\163\141n\144s_se\160");
 ?></b></td>
        </tr>
        <tr valign="top" bgcolor="#eeeeee">
            <td align="right">Amount Financed:</td>
            <td><b><?php echo "\044".number_format($O1bc,"\062",".","th\157u\163\141\156d\163_\163ep");
 ?></b></td>
        </tr>
        <tr valign="top" bgcolor="#cccccc">
            <td align="right">Monthly Payment:</td>
            <td><b><?php echo "\044".number_format($O1b6,"\062","\056","\164\150\157\165s\141nds_\163ep");
 ?></b><br><font>(Principal &amp; Interest ONLY)</font></td>
        </tr>
        <?php if ($l1b4>=024) $O1bd=0;
 else { $O1bd=067*($O1bc/0303240);
 ?>
                <tr valign="top" bgcolor="#FFFFCC">
                    <td align="right">&nbsp;</td>
                    <td>
                        <br>
                        Since you are putting LESS than 20% down, you will need to pay PMI (<a href="http://www.google.com/search?hl=en&q=private+mortgage+insurance">Private Mortgage Insurance</a>), which tends to be about $55 per month for every $100,000 financed (until you have paid off 20% of your loan). This could add <?php echo "\044".number_format($O1bd,"\062","\056","\164h\157\165sa\156ds_se\160");
 ?> to your monthly payment.
                    </td>
                </tr>
                <tr valign="top" bgcolor="#FFFF99">
                    <td align="right">Monthly Payment:</td>
                    <td><b><?php echo "\044".number_format(($O1b6+$O1bd),"\062","\056","\164\150\157\165s\141n\144s_s\145\160");
 ?></b><br><font>(Principal &amp; Interest, and PMI)</td>
                </tr>
        <?php } ?>
        <tr valign="top" bgcolor="#CCCCFF">
            <td align="right">&nbsp;</td>
            <td>
                <br>
                <?php $l1be=($O1b2*.85);
 $O1be=($l1be/01750)*016;
 $l1bf=$O1be/014;
 if ($O1bd == 0) $O1bf="";
 else { $O1bf="\120\115\111\040\141\156d ";
 } ?>
                Residential (or Property) Taxes are a little harder to figure out... In Massachusetts, the average resedential tax rate seems to be around $14 per year for every $1,000 of your property's assessed value.
                <br><br>
                Let's say that your property's <i>assessed value</i> is 85% of what you actually paid for it - <?php echo "\044".number_format($l1be,"\062","\056","\164h\157us\141\156\144s_\163e\160");
 ?>. This would mean that your yearly residential taxes will be around <?php echo "\044".number_format($O1be,"2",".","\164\150\157us\141\156ds\137s\145p");
 ?>
                This could add <?php echo "\044".number_format($l1bf,"\062","\056","\164h\157\165\163\141\156ds\137s\145p");
 ?> to your monthly payment.
            </td>
        </tr>
        <tr valign="top" bgcolor="#9999FF">
            <td align="right">TOTAL Monthly Payment:</td>
            <td><b><?php echo "\044".number_format(($O1b6+$O1bd+$l1bf),"\062",".","\164h\157u\163\141\156ds\137s\145p");
 ?></b><br><font>(including <?php echo $O1bf;
 ?> residential tax)</font></td>
        </tr>
<?php } ?>
</table>
</form>
<?php if ($O1b5 && $l1b6) { $l1bg=1;
 ?>
        <br><br>
        <table cellpadding="5" cellspacing="0" border="1" width="100%">
            <tr valign="top">
                <td><b><?php echo $l1bg ++;
 ?></b></td>
                <td>
                    The <b>down payment</b> = The price of the home multiplied by the percentage down divided by 100 (for 5% down becomes 5/100 or 0.05)<br><br>
                    $<?php echo number_format($O1bb,"\062",".","t\150\157\165sa\156ds_se\160");
 ?> = $<?php echo number_format($O1b2,"\062","\056","t\150\157\165\163ands_sep");
 ?> X (<?php echo $l1b4;
 ?> / 100)
                </td>
            </tr>
            <tr valign="top">
                <td><b><?php echo $l1bg ++;
 ?></b></td>
                <td>
                    The <b>interest rate</b> = The annual interest percentage divided by 100<br><br>
                    <?php echo $l1bc;
 ?> = <?php echo $l1b3;
 ?>% / 100
                </td>
            </tr>
            <tr valign="top" bgcolor="#cccccc">
                <td colspan="2">
                    The <b>monthly factor</b> = The result of the following formula:
                </td>
            </tr>
            <tr valign="top">
                <td><b><?php echo $l1bg ++;
 ?></b></td>
                <td>
                    The <b>monthly interest rate</b> = The annual interest rate divided by 12 (for the 12 months in a year)<br><br>
                    <?php echo $O1b8;
 ?> = <?php echo $l1bc;
 ?> / 12
                </td>
            </tr>
            <tr valign="top">
                <td><b><?php echo $l1bg ++;
 ?></b></td>
                <td>
                    The <b>month term</b> of the loan in months = The number of years you've taken the loan out for times 12<br><br>
                    <?php echo $l1bb;
 ?> Months = <?php echo $O1b3;
 ?> Years X 12
                </td>
            </tr>
            <tr valign="top">
                <td><b><?php echo $l1bg ++;
 ?></b></td>
                <td>
                    The montly payment is figured out using the following formula:<br>
                    Monthly Payment = <?php echo number_format($O1bc,"\062","","");
 ?> * (<?php echo number_format($O1b8,"\064","","");
 ?> / (1 - ((1 + <?php echo number_format($O1b8,"4","","");
 ?>)<sup>-(<?php echo $l1bb;
 ?>)</sup>)))
                    <br><br>
                    The <a href="#amortization">amortization</a> breaks down how much of your monthly payment goes towards the bank's interest, and how much goes into paying off the principal of your loan.
                </td>
            </tr>
        </table>
        <br>
<?php $O1bg=$O1bc;
 $l1bh=1;
 $O1bh=1;
 $l1bi=-($l1bb);
 $O1bi=pow((1+$O1b8),$l1bi);
 $O1b6=$O1bg*($O1b8/(1-$O1bi));
 print ("\074\142\162\076<\142r><\141 n\141me=\042\141\155or\164i\172a\164i\157\156\042\076<\057a\076Am\157\162\164iza\164\151\157\156\040Fo\162\040\115\157\156\164hly P\141\171ment: <\142\076\044".number_format($O1b6,"\062","\056","tho\165\163an\144\163_s\145p")."\074\057\142\076\040\157v\145r\040".$O1b3." \171e\141r\163\074b\162>\n");
 print ("\074\164\141bl\145\040\143el\154pad\144ing\075\042\065\042\040c\145\154l\163\160a\143\151\156g=\042\060\042\040\142\147\143olo\162=\042\043eeee\145\145\042 bor\144\145r\075\0421\042\040\167\151\144th=\042100%\042\076\n");
 $l1bj="\011\074t\162\040\166ali\147n=\042to\160\042 bg\143olo\162=\042#\143\143\143cc\143\042\076\n";
 $l1bj .= "\011\011\074t\144\040\141li\147n\075\042right\042><b>\115o\156t\150<\057b\076<\057\164\144\076\n";
 $l1bj .= "\011\011\074\164\144 \141\154\151gn=\042\162\151g\150t\042\076\074\142>\111\156t\145re\163t \120\141\151d<\057b\076</\164\144\076\n";
 $l1bj .= "\011\011<\164d \141\154ig\156=\042\162\151ght\042>\074\142>\120\162\151\156ci\160a\154\040Pa\151\144<\057b>\074/\164\144\076\n";
 $l1bj .= "\011\011<\164d \141l\151gn\075\042\162ight\042\076\074\142\076\122\145\155a\151\156g\040Ba\154\141n\143\145\074\057b\076</\164\144>\n";
 $l1bj .= "\011\074/\164\162\076\n";
 echo $l1bj;
 while ($l1bh<=$l1bb) { $O1bj=$O1bg*$O1b8;
 $l1bk=$O1b6-$O1bj;
 $O1bk=$O1bg-$l1bk;
 $O1b4=$O1b4+$O1bj;
 $l1b5=$l1b5+$l1bk;
 print ("\011<tr\040v\141\154i\147\156\075\042\164op\042 bg\143ol\157r\075\042\043e\145\145e\145\145\042\076\n");
 print ("\011\011<\164d \141\154ign\075\042\162ight\042\076".$l1bh."\074\057t\144\076\n");
 print ("\011\011<t\144 a\154ign=\042r\151gh\164\042>\044".number_format($O1bj,"2",".","th\157\165s\141\156\144s\137s\145p")."<\057\164d\076\n");
 print ("\011\011\074t\144\040\141\154ign=\042\162\151g\150t\042>\044".number_format($l1bk,"\062",".","\164h\157\165\163\141nd\163_s\145\160")."\074\057t\144\076\n");
 print ("\011\011<\164\144 \141lign\075\042\162ight\042\076\044".number_format($O1bk,"2",".","\164h\157u\163\141\156ds\137se\160")."<\057\164d\076\n");
 print ("\011<\057\164\162\076\n");
 ($l1bh%014) ? $l1bl=FALSE: $l1bl=TRUE;
 if ($l1bl) { print ("\011\074t\162\040v\141\154i\147\156=\042\164op\042 \142gc\157l\157r\075\042#\146\146f\146\143\143\042>\n");
 print ("\011\011\074t\144\040\143o\154s\160an=\0424\042><b\076\124o\164\141\154\163 \146\157r\040y\145\141\162 ".$O1bh."\074\057t\144\076\n");
 print ("\011\074/t\162\076\n");
 $O1bl=$O1b4+$l1b5;
 print ("\011\074t\162\040v\141lign=\042\164op\042 \142gc\157lor\075\042#\146\146\146fc\143\042\076\n");
 print ("\011\011\074t\144\076\046\156b\163p;</\164d>\n");
 print ("\011\011\074t\144 colspan\075\0423\042\076\n");
 print ("\011\011\011\131\157u\040\167i\154l s\160end \044".number_format($O1bl,"\062",".","t\150\157\165sa\156\144s_\163ep")."\040o\156 \171\157u\162 ho\165s\145 \151n year ".$O1bh."\074\142r\076\n");
 print ("\011\011\011\044".number_format($O1b4,"\062","\056","t\150\157us\141nds_sep")."\040\167\151\154l go towa\162ds IN\124ER\105ST<br\076\n");
 print ("\011\011\011\044".number_format($l1b5,"\062",".","\164h\157\165sa\156\144s\137se\160")." w\151\154l\040g\157 t\157war\144s P\122INCIPAL<br\076\n");
 print ("\011\011\074/\164\144>\n");
 print ("\011\074/\164r>\n");
 print ("\011<\164\162\040\166a\154\151gn=\042\164\157p\042 \142gc\157\154o\162=\042#\146f\146\146\146f\042>\n");
 print ("\011\011<t\144\040colspa\156=\042\064\042\076\046\156bs\160;\074b\162>\074b\162\076<\057t\144\076\n");
 print ("\011\074\057t\162\076\n");
 $O1bh ++;
 $O1b4=0;
 $l1b5=0;
 if (($l1bh+6)<$l1bb) { echo $l1bj;
 } } $O1bg=$O1bk;
 $l1bh ++;
 } print ("</\164\141\142\154e\076\n");
 } ?>
<br>

<!-- END BODY -->


<?php if ($O1b7) { print ("\074/\142\157dy\076\n");
 print ("\074\057\102\117\104Y>\n<\057\110TML\076\n");
 } ?>

<?php
     /*
         ///// mortgage_calculator.php /////
         Copyright (c) 2002 David Tufts <http://dave.imarc.net> 
         All rights reserved.
         
         Redistribution and use in source and binary forms, with or without 
         modification, are permitted provided that the following conditions 
         are met:
         
         *    Redistributions of source code must retain the above copyright 
          notice, this list of conditions and the following disclaimer.
         *    Redistributions in binary form must reproduce the above 
          copyright notice, this list of conditions and the following 
          disclaimer in the documentation and/or other materials 
          provided with the distribution.
         *    Neither the name of David Tufts nor the names of its 
          contributors may be used to endorse or promote products 
          derived from this software without specific prior 
          written permission.
         
         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
         CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
         INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
         MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
         DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
         BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
         EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
         TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
         ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
         OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
         OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
         POSSIBILITY OF SUCH DAMAGE.
     */
     ;
 ?> 

Obfuscated Symbol Cross Reference

The obfuscator produces a cross reference mapping obfuscated symbols to the orginal symbols, so that obfuscated code in the field can still be decoded if necessary. In fact, by reversing this map, the obfuscator can unobfuscate the code (of course, it cannot restore the comments). Of course, you can only do this, if you have the map, which you can only have obtained by running the obfuscator on the original code.


### Obfuscated Identifiers ###
$annual_interest_percent -> $l1b3
$annual_interest_rate -> $l1bc
$assessed_price -> $l1be
$base_rate -> $l1b9
$current_month -> $l1bh
$current_year -> $O1bh
$default_annual_interest_percent -> $O1b0
$default_down_percent -> $O1b1
$default_sale_price -> $l1b0
$default_show_progress -> $l1b2
$default_year_term -> $l1b1
$denom -> $O1bi
$denominator -> $l1ba
$down_payment -> $O1bb
$down_percent -> $l1b4
$error -> $l1b7
$factor -> $O1b9
$financing_price -> $O1bc
$form_complete -> $O1b5
$i -> $O1ba
$interest_paid -> $O1bj
$legend -> $l1bj
$month_term -> $l1bb
$monthly_factor -> $l1bd
$monthly_interest_rate -> $O1b8
$monthly_payment -> $O1b6
$pmi_per_month -> $O1bd
$pmi_text -> $O1bf
$power -> $l1bi
$principal -> $O1bg
$principal_paid -> $l1bk
$print_footer -> $O1b7
$remaining_balance -> $O1bk
$residential_monthly_tax -> $l1bf
$residential_yearly_tax -> $O1be
$sale_price -> $O1b2
$show_legend -> $l1bl
$show_progress -> $l1b6
$step -> $l1bg
$this_year_interest_paid -> $O1b4
$this_year_principal_paid -> $l1b5
$total_spent_this_year -> $O1bl
$year_term -> $O1b3
get_interest_factor -> l1b8
For more information: [email protected]    Follow us at Twitter: @SemanticDesigns

PHP Obfuscation
Example