function check_order_status($start = false)
 {
     global $PayPal_osC, $customers_id;
     include_once PAYPAL_IPN_DIR . 'database_tables.inc.php';
     if (olc_session_is_registered('PayPal_osC')) {
         if ($start === true && PHP_VERSION < 4) {
             $PayPal_osC_backup = $PayPal_osC;
             $PayPal_osC = new PayPal_osC();
             $PayPal_osC->unserialize($PayPal_osC_backup);
         }
         $orders_session_query = olc_db_query("select payment_id from " . TABLE_ORDERS . " where orders_id = " . (int) $PayPal_osC->orders_id);
         $orders_session_check = olc_db_fetch_array($orders_session_query);
         if ($orders_session_check['payment_id'] > 0) {
             PayPal_osC::reset_checkout_cart_session();
             return true;
         }
         return false;
     }
     return false;
 }
 function before_process()
 {
     if (!class_exists('PayPal_osC')) {
         include_once PAYPAL_IPN_DIR . 'Classes/osC/osC.class.php';
     }
     if (PayPal_osC::check_order_status()) {
         olc_redirect(olc_href_link(FILENAME_SHOPPING_CART, EMPTY_STRING, SSL));
     } else {
         include PAYPAL_IPN_DIR . 'catalog/checkout_process.inc.php';
     }
     exit;
 }
if (!defined('USE_PAYPAL_IPN')) {
    define('USE_PAYPAL_IPN', IS_LOCAL_HOST);
}
if (!defined('USE_PAYPAL_WPP')) {
    define('USE_PAYPAL_WPP', IS_LOCAL_HOST);
}
$paypal_ipn_text = 'paypal_ipn';
define('PAYPAL_IPN_DIR', ADMIN_PATH_PREFIX . DIR_WS_MODULES . 'payment' . SLASH . $paypal_ipn_text . SLASH);
$paypal_scripts = FILENAME_EC_PROCESS . FILENAME_IPN . $paypal_ipn_text . PHP;
if (strpos(CURRENT_SCRIPT, 'checkout_') !== false or strpos($paypal_scripts, CURRENT_SCRIPT) !== false) {
    if (USE_PAYPAL_IPN) {
        // begin PayPal_Shopping_Cart_IPN
        require_once PAYPAL_IPN_DIR . 'Classes/osC/osC.class.php';
        // end PayPal_Shopping_Cart_IPN
        // begin PayPal_Shopping_Cart_IPN
        PayPal_osC::check_order_status(true);
        // end PayPal_Shopping_Cart_IPN
        if (strpos(CURRENT_SCRIPT, "ipn.") !== false) {
            define('IPN_PAYMENT_MODULE_NAME', 'PayPal_Shopping_Cart_IPN');
            require PAYPAL_IPN_DIR . 'database_tables.inc.php';
            include PAYPAL_IPN_DIR . 'Classes/osC/Order.class.php';
            $PayPal_osC_Order = new PayPal_osC_Order();
            $PayPal_osC_Order->loadTransactionSessionInfo($_POST['custom']);
            if (isset($PayPal_osC_Order->language)) {
                // include the language translations
                $language = $PayPal_osC_Order->language;
                include DIR_WS_LANGUAGES . $language . PHP;
            } else {
                //later on change to Store Default
                include PAYPAL_IPN_DIR . 'languages/' . SESSION_LANGUAGE . PHP;
            }
    }
    if (CUSTOMER_STATUS_ID != DEFAULT_CUSTOMERS_STATUS_ID_GUEST) {
        olc_redirect(olc_href_link(FILENAME_DEFAULT, $notify_string));
    }
    //begin PayPal_Shopping_Cart_IPN
    /*
    } else {
    olc_redirect(olc_href_link(FILENAME_LOGOFF, $notify_string));
    }
    */
} else {
    if ($action == 'success') {
        if (!class_exists('PayPal_osC')) {
            include_once PAYPAL_IPN_DIR . 'Classes/osC/osC.class.php';
        }
        PayPal_osC::reset_checkout_cart_session();
    } else {
        olc_redirect(olc_href_link(FILENAME_LOGOFF, $notify_string));
    }
}
//end PayPal_Shopping_Cart_IPN
// include needed functions
require_once DIR_FS_INC . 'olc_draw_checkbox_field.inc.php';
require_once DIR_FS_INC . 'olc_draw_selection_field.inc.php';
require_once DIR_FS_INC . 'olc_image_button.inc.php';
$breadcrumb->add(NAVBAR_TITLE_1_CHECKOUT_SUCCESS);
$breadcrumb->add(NAVBAR_TITLE_2_CHECKOUT_SUCCESS);
$global_query = olc_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int) $_SESSION['customer_id'] . APOS);
$global = olc_db_fetch_array($global_query);
$orders_query = olc_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int) $_SESSION['customer_id'] . "' order by date_purchased desc limit 1");
$orders = olc_db_fetch_array($orders_query);