}
} else {
    define('AJAX_TITLE', $breadcrumb->title_from_trail());
}
echo $body;
// include needed functions
require_once DIR_FS_INC . 'olc_image.inc.php';
require_once DIR_FS_INC . 'olc_parse_input_field_data.inc.php';
require_once DIR_FS_INC . 'olc_draw_separator.inc.php';
if ($IsNormalMode) {
    $smarty->assign('navtrail', $breadcrumb->trail(' >> '));
    //W. Kaiser - AJAX
    //---PayPal WPP Modification START ---//
    $is_logogff = CURRENT_SCRIPT == FILENAME_LOGOFF;
    if (CUSTOMER_ID) {
        $paypal_ec_temp = $_SESSION['paypal_ec_temp'];
        if (olc_paypal_wpp_enabled() && $paypal_ec_temp) {
            //If this is a temp account that'll be deleted, don't show account information
            if ($paypal_ec_temp) {
                $is_logogff = true;
                //Fake "Logoff"-state
            }
        }
    }
    //---PayPal WPP Modification END ---//
    if (NOT_IS_AJAX_PROCESSING || CURRENT_SCRIPT == FILENAME_LOGIN || $is_logogff) {
        include_once DIR_FS_INC . 'olc_create_navigation_links.inc.php';
        olc_create_navigation_links(count($_SESSION['cart']->contents) > 0, $is_logogff);
    }
}
//W. Kaiser - AJAX
if (STOCK_CHECK == TRUE_STRING_S) {
    if (STOCK_ALLOW_CHECKOUT != TRUE_STRING_S) {
        $products = $_SESSION['cart']->get_products();
        $any_out_of_stock = 0;
        for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
            if (olc_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
                $any_out_of_stock = 1;
            }
        }
        if ($any_out_of_stock == 1) {
            olc_redirect(olc_href_link(FILENAME_SHOPPING_CART));
        }
    }
}
//---PayPal WPP Modification START ---//
$ec_enabled = olc_paypal_wpp_enabled();
if ($ec_enabled) {
    if ($_SESSION['paypal_error']) {
        $checkout_login = true;
        $messageStack->add('payment', $paypal_error);
        unset($_SESSION['paypal_error']);
    }
}
//---PayPal WPP Modification END ---//
// if no billing destination address was selected, use the customers own address as default
if (isset($_SESSION['billto'])) {
    // verify the selected billing address
    $check_address_query = olc_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . CUSTOMER_ID . "' and address_book_id = '" . (int) $_SESSION['billto'] . APOS);
    $check_address = olc_db_fetch_array($check_address_query);
    if ($check_address['total'] != '1') {
        $_SESSION['billto'] = $_SESSION['customer_default_address_id'];
<?php

/*
ec_process.php -- PayPal WPP Easy Checkout

Copyright (c) 2005 Mr. Brian Burton - brian@dynamoeffects.com
Copyright (c) 2006 Dipl.-Ing.(TH) Winfried Kaiser (w.kaiser@fortune.de) -- Port to OL-Commerce

Released under the GNU General Public License
*/
require 'includes/application_top.php';
require_once DIR_FS_INC . 'olc_paypal_wpp_enabled.inc.php';
if (olc_paypal_wpp_enabled()) {
    unset($_SESSION['paypal_error']);
    $paypal_ec_text = 'paypal_ec_';
    if ($_GET['clearSess']) {
        unset($_SESSION[$paypal_ec_text . 'temp']);
        unset($_SESSION[$paypal_ec_text . 'token']);
        unset($_SESSION[$paypal_ec_text . 'payer_id']);
        unset($_SESSION[$paypal_ec_text . 'payer_info']);
    }
    if ($_SESSION[$paypal_ec_text . 'token']) {
        require DIR_WS_LANGUAGES . SESSION_LANGUAGE . SLASH . FILENAME_EC_PROCESS;
        require DIR_WS_CLASSES . 'payment.php';
        $payment_modules = new payment('paypal_wpp');
        $payment_modules->ec_step2();
    } else {
        if ($_GET['action'] == 'process') {
            //W. Kaiser - AJAX
            $error_message = EMPTY_STRING;
            if (!$_POST['conditions']) {