Completed
Pull Request — master (#2)
by
unknown
01:38
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
include '../../mainfile.php';
3
include XOOPS_ROOT_PATH . '/modules/martin/include/common.php';
4
if (!defined('MODULE_URL')) {
5
    define('MODULE_URL', XOOPS_URL . '/modules/martin/');
6
}
7
8
global $xoopsUser;
9
if (!$xoopsUser) {
10
    redirect_header(XOOPS_URL . '/user.php?xoops_redirect=/' . $_SERVER['REQUEST_URI'], 1, '您还没有登录.');
11
}
12
13
$cart_handler  =& xoops_getmodulehandler("cart", 'martin');
14
$hotel_handler =& xoops_getmodulehandler("hotel", 'martin');
15
16
$order_id  = isset($_GET['order_id']) ? (int)($_GET['order_id']) : 0;
17
$order_id  = isset($_POST['order_id']) ? (int)($_POST['order_id']) : $order_id;
18
$order_pay = isset($_POST['order_pay']) ? trim($_POST['order_pay']) : null;
19
if (!$order_id) {
20
    redirect_header(XOOPS_URL, 1, _AM_MARTIN_ILLEGAL_OPERATION);
21
}
22
if ($_POST && !$order_pay) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $order_pay of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
23
    redirect_header('javascript:history.go(-1);', 1, _AM_MARTIN_NO_CHOICE_OF_PAYMENT);
24
}
25
$order_pay_method = is_numeric($order_pay) ? 2 : 1;
26
27
$order = $cart_handler->GetOrderInfo($order_id);
28
if (!$order) {
29
    redirect_header(XOOPS_URL, 1, _AM_MARTIN_ILLEGAL_OPERATION);
30
}
31
if ($cart_handler->CheckOrderClose($order_id)) {
32
    redirect_header(XOOPS_URL . '/hotel/', 1, _AM_MARTIN_ORDER_PAID);
33
}
34
35
//var_dump($order);
36
37
if ($order_id > 0 && !empty($order_pay) && $order_pay_method > 0) {
38
    if ($cart_handler->ChangeOrderPay($order_id, $order_pay_method, $order_pay)) {
39
        if ($order_pay_method == 2) {
40
            $msg        = _AM_MARTIN_ORDER_RECEIVED_BOOKING_AFTER_PAYMENT;
41
            $change_url = XOOPS_URL . '/hotel/';
42
        } else {
43
            $pay_file = MARTIN_ROOT_PATH . "pay/$order_pay/$order_pay.php";
44
            if (file_exists($pay_file)) {
45
                include $pay_file;
46
            }
47
            exit;
48
            $msg        = _AM_MARTIN_GOING_TO_PAYMENT_PAGE;
49
            $change_url = XOOPS_URL . '/hotel/';
50
        }
51
        redirect_header($change_url, 2, $msg);
52
        exit;
53
    } else {
54
        redirect_header('javascript:history.go(-1);', 1, _AM_MARTIN_NO_CHOICE_OF_PAYMENT);
55
    }
56
}
57
58
//var_dump($order['order_pay']);
59
$xoopsOption["template_main"] = "martin_hotel_pay.tpl";
60
include XOOPS_ROOT_PATH . '/header.php';
61
include XOOPS_ROOT_PATH . '/modules/martin/HotelSearchLeft.php';
62
63
$xoopsOption['xoops_pagetitle'] = _AM_MARTIN_PAYMENT_OPTIONS;// - '.$xoopsConfig['sitename'];
64
$xoopsTpl->assign("xoops_pagetitle", $xoopsOption["xoops_pagetitle"]);
65
$xoopsTpl->assign('hotel_static_prefix', $xoopsModuleConfig['hotel_static_prefix']);
66
$xoopsTpl->assign('module_url', MODULE_URL);
67
$xoopsTpl->assign('order_id', $order_id);
68
$xoopsTpl->assign('order_pay', $order['order_pay']);
69
$xoopsTpl->assign('order_pay_str', $order['order_pay_str']);
70
$xoopsTpl->assign('line_pays', getModuleArray('line_pays', 'line_pays', true));
71
$xoopsTpl->assign('online_pays', getModuleArray('online_pays', 'online_pays', true));
72
73
include XOOPS_ROOT_PATH . '/footer.php';
74