mambax7 /
xoops-martin
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 | |||
| 5 | global $xoopsUser; |
||
|
0 ignored issues
–
show
|
|||
| 6 | |||
| 7 | if (!$xoopsUser) { |
||
| 8 | redirect_header(XOOPS_URL . '/user.php?xoops_redirect=/' . $_SERVER['REQUEST_URI'], 1, '您还没有登录.'); |
||
| 9 | } |
||
| 10 | |||
| 11 | $group_id = isset($_GET['group_id']) ? (int)($_GET['group_id']) : $id; |
||
| 12 | $group_id = isset($_POST['group_id']) ? (int)($_POST['group_id']) : $group_id; |
||
| 13 | if (!$group_id) { |
||
| 14 | redirect_header(XOOPS_URL, 3, _AM_MARTIN_UNAUTHORIZED_ACCESS); |
||
| 15 | } |
||
| 16 | |||
| 17 | $group_handler =& xoops_getmodulehandler("group", 'martin'); |
||
| 18 | $hotel_handler =& xoops_getmodulehandler("hotel", 'martin'); |
||
| 19 | $group_obj = $group_handler->get($group_id); |
||
| 20 | |||
| 21 | //判断是否存在 |
||
| 22 | if (!$group_obj->group_id()) { |
||
| 23 | redirect_header(XOOPS_URL, 3, _AM_MARTIN_UNAUTHORIZED_ACCESS); |
||
| 24 | } |
||
| 25 | //是否结束 |
||
| 26 | if ($group_obj->apply_end_date() < time()) { |
||
| 27 | redirect_header(XOOPS_URL, 3, '该团购已经结束.'); |
||
| 28 | } |
||
| 29 | |||
| 30 | //参加团购 |
||
| 31 | $uid = $xoopsUser->getVar('uid'); |
||
| 32 | $action = isset($_GET['action']) ? trim($_GET['action']) : null; |
||
| 33 | $room_number = isset($_POST['room_number']) ? (int)($_POST['room_number']) : 1; |
||
| 34 | if ($action === 'save') { |
||
| 35 | $data = array('uid' => $uid, 'group_id' => $group_id, 'room_number' => $room_number, 'join_time' => time()); |
||
| 36 | if ($group_handler->CheckJoinExist($data)) { |
||
| 37 | redirect_header('javascript:history.go(-1);', 2, '您已经参加过了.'); |
||
| 38 | } elseif ($group_handler->AddUserGroup($data)) { |
||
| 39 | redirect_header(XOOPS_URL . '/modules/martin/group.php/group-' . $group_id . $xoopsModuleConfig['hotel_static_prefix'], 2, '提交成功.'); |
||
| 40 | } else { |
||
| 41 | redirect_header('javascript:history.go(-1);', 2, '提交失败.'); |
||
| 42 | } |
||
| 43 | exit(); |
||
| 44 | } |
||
| 45 | |||
| 46 | $group_data = array(); |
||
| 47 | foreach ($group_obj->vars as $key => $var) { |
||
| 48 | $group_data[$key] = $group_obj->$key(); |
||
| 49 | } |
||
| 50 | |||
| 51 | $rooms = $group_handler->GetGroupRooms($group_id); |
||
| 52 | //var_dump($rooms); |
||
| 53 | $CityAlias = $search_handler->GetCityAlias(); |
||
| 54 | |||
| 55 | //user |
||
| 56 | $xoopsUser->cleanVars(); |
||
| 57 | $user =& $xoopsUser->cleanVars; |
||
| 58 | |||
| 59 | $GroupDate = array( |
||
| 60 | 'min' => (int)($group_obj->check_in_date() - strtotime(date('Y-m-d'))) / (3600 * 24), |
||
| 61 | 'max' => (int)($group_obj->check_out_date() - strtotime(date('Y-m-d'))) / (3600 * 24),); |
||
| 62 | //var_dump($GroupDate); |
||
| 63 | |||
| 64 | $GroupStatus = time() < $group_data['apply_start_date'] ? array('title' => '召集中', 'status' => false) : ''; |
||
| 65 | $GroupStatus = (time() <= $group_data['apply_end_date'] && time() >= $group_data['apply_start_date']) ? array('title' => '进行中', 'status' => true) : $GroupStatus; |
||
| 66 | $GroupStatus = time() >= $group_data['apply_end_date'] ? array('title' => '已结束', 'status' => false) : $GroupStatus; |
||
| 67 | |||
| 68 | $xoopsOption["template_main"] = "martin_group.tpl"; |
||
| 69 | |||
| 70 | $joins = $group_handler->getGroupJoinList($group_id); |
||
| 71 | //var_dump($joins); |
||
| 72 | |||
| 73 | include XOOPS_ROOT_PATH . '/header.php'; |
||
| 74 | include XOOPS_ROOT_PATH . '/modules/martin/HotelSearchLeft.php'; |
||
| 75 | |||
| 76 | $xoopsOption['xoops_pagetitle'] = $group_obj->group_name() . ' - ' . _AM_MARTIN_HOTEL_GROUP_BUY;// - '.$xoopsConfig['sitename']; |
||
| 77 | |||
| 78 | $xoopsTpl->assign("xoops_pagetitle", $xoopsOption["xoops_pagetitle"]); |
||
| 79 | $xoopsTpl->assign("module_url", XOOPS_URL . '/modules/martin/'); |
||
| 80 | $xoopsTpl->assign('group_id', $group_id); |
||
| 81 | $xoopsTpl->assign('group', $group_data); |
||
| 82 | $xoopsTpl->assign('rooms', $rooms); |
||
| 83 | $xoopsTpl->assign('GroupStatus', $GroupStatus); |
||
| 84 | $xoopsTpl->assign('user', $user); |
||
| 85 | $xoopsTpl->assign('groupdate', $GroupDate); |
||
| 86 | $xoopsTpl->assign('alias', $CityAlias); |
||
| 87 | $xoopsTpl->assign('joins', $joins); |
||
| 88 | $xoopsTpl->assign('hotel_static_prefix', $xoopsModuleConfig['hotel_static_prefix']); |
||
| 89 | |||
| 90 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
| 91 |
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state