Example #1
0
abr('item', $item);
#BUY ITEM
//购买作品
if (isset($_SESSION['tmp']['order_id']) && $_SESSION['tmp']['order_id']) {
    $_SESSION['tmp']['order_id'] = 0;
}
if (isset($_POST['licence'])) {
    if (!check_login_bool()) {
        $_SESSION['temp']['golink'] = '/' . $languageURL . 'items/' . $itemID;
        refresh('/' . $languageURL . 'sign_in/');
    }
    $ordersClass = new orders();
    if ($_POST['licence'] == 'regular') {
        //余额购买作品
        if (isset($_POST['pay_method']) && $_POST['pay_method'] == 'paymethod') {
            $orderID = $ordersClass->add($item['price']);
            if (isset($_SESSION['tmp']['deposit_id'])) {
                unset($_SESSION['tmp']['deposit_id']);
            }
            $_SESSION['tmp']['order_id'] = $orderID;
            refresh('/' . $languageURL . 'items/payment/');
        } else {
            //判断余额
            if ($_SESSION['user']['total'] < $item['prepaid_price']) {
                addErrorMessage($langArray['error_not_enought_money'], '', 'error');
            } else {
                $total_money = floatval($item['prepaid_price']) + floatval($item['your_profit']);
                $ordersClass->buy($total_money);
                refresh('/' . $languageURL . 'download/', $langArray['complete_buy_theme'], 'complete');
            }
        }
                    $smarty->assign('to', $_POST['to']);
                    $smarty->assign('weight', $_POST['weight']);
                    $smarty->assign('proceed', $proceed);
                }
            } else {
                echo "COMPLETE INFORMATION NECCESSARY";
            }
        }
        if (isset($_POST['payNow'])) {
            $order = new orders();
            $order->add($_SESSION['userid'], $_POST['from'], $_POST['to'], $_POST['weight'], 0);
            echo "thankyou";
        }
        if (isset($_POST['POD'])) {
            echo "thankyou";
            $order = new orders();
            $order->add($_SESSION['userid'], $_POST['from'], $_POST['to'], $_POST['weight'], 1);
        }
        $route = new routes();
        $allRoutes = $route->getAll();
        $smarty->assign('allRoutes', $allRoutes);
        $smarty->display('neworder.tpl');
        //include neworder template
        $smarty->display('footer.tpl');
        //include footer file
    } else {
        header('Location:' . URL . 'notauthorised.php');
    }
} else {
    header('Location:' . URL . 'noaccess.php');
}