-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstep2.php
More file actions
70 lines (58 loc) · 2.09 KB
/
step2.php
File metadata and controls
70 lines (58 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/*
step2.php
This page should be invisible to the user
they will be redirected from here to TourCMS
then subsequently on to step3.php
*/
// Include the config file
include('inc/config.php');
// Process the form
// We don't actually need any of this on this step, we will just be passing it on
// in the querystring to Step 3
$qs = "";
// Tour ID
isset($_POST['tour']) ? $tour = $_POST['tour'] : exit();
$qs .= "?tour=" . $tour;
// Channel ID
isset($_POST['channel']) ? $channel = $_POST['channel'] : exit();
$qs .= "&channel=" . $channel;
// Date
isset($_POST['date']) ? $date = $_POST['date'] : $date = "";
$qs .= "&date=" . $date;
// Duration
isset($_POST['hdur']) ? $hdur = $_POST['hdur'] : $hdur = "";
$qs .= "&hdur=" . $hdur;
// Rates & number of people
isset($_POST['rates']) ? $rate_string = $_POST['rates'] : exit();
$qs .= "&rates=" . $rate_string;
$rates = explode(",", $rate_string);
$total_people = 0;
foreach ($rates as $rate) {
if(isset($_POST[$rate])) {
$rate_count = (int)$_POST[$rate];
if($rate_count > 0) {
$qs .= "&" . $rate . "=" . $rate_count;
$total_people += $rate_count;
}
}
}
$qs .= "&total_people=" . $total_people;
// If this is a Marketplace partner we can just redirect to Step 3
if($marketplace_account_id > 0) {
header("Location: " . $response_url . $qs);
exit();
}
// Otherwise we need to redirect via TourCMS
// Create a new SimpleXMLElement to hold the response url
$url_data = new SimpleXMLElement('<url />');
$url_data->addChild('response_url', htmlentities($response_url . $qs));
// Send the response URL to TourCMS
$result = $tourcms->get_booking_redirect_url($url_data, $channel);
// TourCMS should have returned a URL back to us, get that
$redirect_url = $result->url->redirect_url;
// Redirect the customer to the URL obtained from TourCMS
// Comment these next two lines if you want to see the data sent and returned
header("Location: " . $redirect_url);
exit();
?><pre><?php htmlentities(print($url_data->asXML())); ?></pre><pre><?php print_r($result); ?></pre><pre><?php print $redirect_url; ?></pre>