commit af0b1de88caa25c5dda36891942421af8b6bbac6 Author: James Pattinson Date: Tue Feb 11 16:14:49 2025 +0000 first commit diff --git a/action.php b/action.php new file mode 100644 index 0000000..1283c74 --- /dev/null +++ b/action.php @@ -0,0 +1,148 @@ + + + + + + + Row Details + + + + +query($sql); +} + +function opLanded() { + $conn = connectDb(); + $sql = "UPDATE submitted SET status = 'LANDED', landed_dt = NOW() where id = " . $_GET['id']; + $result = $conn->query($sql); +} + +function opDetail() { + $conn = connectDb(); + $sql = "SELECT * FROM submitted WHERE id = " . $_GET['id']; + $result = $conn->query($sql); + + if ($result->num_rows > 0) { + // Output data of the row + $row = $result->fetch_assoc(); + echo '
'; + echo '

Aircraft Reg: ' . $row['ac_reg'] . "

"; + echo "

Aircraft Type: " . $row['ac_type'] . "

"; + echo "

Callsign: " . $row['ac_call'] . "

"; + echo "

Captain's Name: " . $row['captain'] . "

"; + echo "

Arriving From: " . $row['in_from'] . "

"; + echo "

POB IN: " . $row['pob_in'] . "

"; + echo "

ETA: " . $row['eta'] . "

"; + + echo "

Fuel Required: " . $row['fuel'] . "

"; + + echo "

POB OUT: " . $row['pob_out'] . "

"; + echo "

Outbound To: " . $row['out_to'] . "

"; + echo "

ETD: " . $row['etd'] . "

"; + + + echo "

Email Address: " . $row['email'] . "

"; + echo "

Phone: " . $row['phone'] . "

"; + + + echo "

Notes: " . $row['notes'] . "

"; + echo "

PPR created at: " . $row['submitted_dt'] . " by " . $row['created_by'] . "

"; + + } else { + echo "No details found for the given ID."; + + } +} + +switch($_GET['op']) { + case "cancel": + opCancel(); + break; + case "landed": + opLanded(); + break; + case "detail": + opDetail(); + break; + + default: + +} + +?> +

+ diff --git a/adduser.php b/adduser.php new file mode 100644 index 0000000..d788006 --- /dev/null +++ b/adduser.php @@ -0,0 +1,18 @@ +prepare("INSERT INTO users (username, password) VALUES (?, ?)"); +$stmt->bind_param("ss", $username, $hashedPassword); +$stmt->execute(); +$stmt->close(); + +echo "User added successfully!"; +$conn->close(); +?> \ No newline at end of file diff --git a/arrivals.php b/arrivals.php new file mode 100644 index 0000000..cb06cb9 --- /dev/null +++ b/arrivals.php @@ -0,0 +1,146 @@ + + + + + + + + + + Swansea Daily PPR + + + + +

Swansea Inbound PPR

+ + 'Custom Heading 1', + 'column2' => 'Custom Heading 2', + 'column3' => 'Custom Heading 3' + // Add more custom headings as needed +]; + +// Define your SQL query +$sql = "SELECT ac_reg, ac_type, ac_call, TIME_FORMAT(eta,'%H:%i') AS ETA, fuel, in_from, pob_in FROM submitted WHERE DATE(eta) = CURDATE() AND status = 'NEW' ORDER BY eta ASC;"; // Replace with your table name + +// Execute the query +$result = $conn->query($sql); + +// Check if there are results +if ($result->num_rows > 0) { + // Start HTML table + echo ' + + '; + + // Output table headers (assuming column names are known) + $fields = $result->fetch_fields(); + foreach ($fields as $field) { + if ($field->name != 'ac_call') { + echo ''; + } + } + + echo ' + + '; + + // Output table rows + while ($row = $result->fetch_assoc()) { + echo ''; + foreach ($row as $key => $value) { + if ($key != 'id' && $key != 'ac_call') { + if ($key == 'ac_reg' && $row['ac_call'] != NULL) { + echo ''; + } else { + echo ''; + } + + } + } + echo ''; + } + + echo ' +
' . htmlspecialchars($field->name ?? '') . '
' . htmlspecialchars($row['ac_call'] ?? '') . "
" . $value . '
' . htmlspecialchars($value ?? '') . '
'; +} else { + echo "No results found."; +} + +// Close the database connection +$conn->close(); +?> diff --git a/cancel-icon.webp b/cancel-icon.webp new file mode 100644 index 0000000..130f63b Binary files /dev/null and b/cancel-icon.webp differ diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..c078d2c --- /dev/null +++ b/functions.php @@ -0,0 +1,74 @@ +connect_error) { + die("Connection failed: " . $conn->connect_error); + } + + return $conn; + +} + +function require_db_auth() { + + if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) { + send_auth_headers(); + } + + $user = $_SERVER['PHP_AUTH_USER']; + $pass = $_SERVER['PHP_AUTH_PW']; + + $conn = connectDb(); + + $stmt = $conn->prepare("SELECT password FROM users WHERE username = ?"); + $stmt->bind_param("s", $user); + $stmt->execute(); + $stmt->store_result(); + $stmt->bind_result($stored_hash); + $stmt->fetch(); + + // Verify the password + if ($stmt->num_rows == 0 || !password_verify($pass, $stored_hash)) { + send_auth_headers(); + } + + // Close the connection + $stmt->close(); + $conn->close(); + +} + +function send_auth_headers() { + header('WWW-Authenticate: Basic realm="Restricted Area"'); + header('HTTP/1.0 401 Unauthorized'); + die("Authentication required."); +} + +function require_auth() { + $AUTH_USER = 'admin'; + $AUTH_PASS = 'admin'; + header('Cache-Control: no-cache, must-revalidate, max-age=0'); + $has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW'])); + $is_not_authenticated = ( + !$has_supplied_credentials || + $_SERVER['PHP_AUTH_USER'] != $AUTH_USER || + $_SERVER['PHP_AUTH_PW'] != $AUTH_PASS + ); + if ($is_not_authenticated) { + header('HTTP/1.1 401 Authorization Required'); + header('WWW-Authenticate: Basic realm="PPR"'); + echo 'Text to send if user hits Cancel button'; + exit; + } +} \ No newline at end of file diff --git a/input.html b/input.html new file mode 100644 index 0000000..6d999ed --- /dev/null +++ b/input.html @@ -0,0 +1,188 @@ + + + + + + + + Manual PPR + + + + +
+

Log new PPR

+
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+ +
+ + +
+ + + +
+ + + diff --git a/land.webp b/land.webp new file mode 100644 index 0000000..e2b5aa6 Binary files /dev/null and b/land.webp differ diff --git a/lookup.php b/lookup.php new file mode 100644 index 0000000..61aa740 --- /dev/null +++ b/lookup.php @@ -0,0 +1,27 @@ +query($sql); + +// Fetch data +$data = []; +if ($result->num_rows > 0) { + while ($row = $result->fetch_assoc()) { + $data[] = $row; + } +} + +// Close connection +$conn->close(); + +// Return JSON output +header('Content-Type: application/json'); +echo json_encode($data, JSON_PRETTY_PRINT); + +?> + diff --git a/newppr.php b/newppr.php new file mode 100644 index 0000000..b7eddae --- /dev/null +++ b/newppr.php @@ -0,0 +1,36 @@ +Received POST Data:"; + echo ""; +} else { + echo "

No POST data received.

"; +} + +?> + diff --git a/testhook.json b/testhook.json new file mode 100644 index 0000000..0f4422d --- /dev/null +++ b/testhook.json @@ -0,0 +1,79 @@ +{ + "form_title": "PPR Request Form", + "form_slug": "ppr-request-form-joclld", + "submission": { + "Aircraft Registration": "G-BJAJ", + "Aircraft Type": "AA5", + "Callsign": "TEST1", + "Captain or PIC Name": "TESTY MCTESTFACE", + "Arriving From": "Wellesbourne", + "ETA": "11\/02\/2025 14:33", + "POB Inbound": "2", + "Fuel Required": "100LL", + "Departing To": "Pembrey", + "ETD": "12\/02\/2025 00:00", + "POB Outbound": "2", + "Email": "james@pattinson.org", + "Phone Number": "+441212121212", + "Additional Information": "Here are some notes man" + }, + "data": { + "617dd0cd-2d17-4d7f-826b-5348afdb30b3": { + "value": "G-BJAJ", + "name": "Aircraft Registration" + }, + "148a55d8-5357-49a3-b9aa-2a5d4dc64173": { + "value": "AA5", + "name": "Aircraft Type" + }, + "52d7bc90-9d26-48a1-82db-b91b4ccd2f92": { + "value": "TEST1", + "name": "Callsign" + }, + "49b2de0d-5bd6-4b0c-86dd-b18b85f8b8ff": { + "value": "TESTY MCTESTFACE", + "name": "Captain or PIC Name" + }, + "4b4f7ecd-f80c-4e86-a7ab-6fadb3220df8": { + "value": "Wellesbourne", + "name": "Arriving From" + }, + "ca4ac44f-0388-4a70-a072-38276ed2ac13": { + "value": "11\/02\/2025 14:33", + "name": "ETA" + }, + "6fc47c54-7383-48fd-93fc-d8080f5ed8f5": { + "value": "2", + "name": "POB Inbound" + }, + "d153c8a5-8345-4e6a-abfd-cf8adcc06f2d": { + "value": "100LL", + "name": "Fuel Required" + }, + "ba95fd3f-1ec0-4553-95d3-a0b6a850738d": { + "value": "Pembrey", + "name": "Departing To" + }, + "53d60abd-eb75-4b1f-92b6-5d47d26367ec": { + "value": "12\/02\/2025 00:00", + "name": "ETD" + }, + "d1ac0860-31f4-4914-9d0b-cae42dfc7eda": { + "value": "2", + "name": "POB Outbound" + }, + "0198c86c-edd1-4aaf-93a1-d68f8fc8c365": { + "value": "james@pattinson.org", + "name": "Email" + }, + "e40ebc2d-887b-42b3-931d-c981c76b0c20": { + "value": "+441212121212", + "name": "Phone Number" + }, + "73d26c2c-1d3d-44e2-82fc-3a1a2600c393": { + "value": "Here are some notes man", + "name": "Additional Information" + } + }, + "message": "Please do not use the `submission` field. It is deprecated and will be removed in the future." +} \ No newline at end of file diff --git a/tower.php b/tower.php new file mode 100644 index 0000000..2b13772 --- /dev/null +++ b/tower.php @@ -0,0 +1,202 @@ + + + + + + + + + + Swansea Daily PPR + + + + + +

Swansea Inbound PPR

+ +connect_error) { + die("Connection failed: " . $conn->connect_error); +} + +$custom_headings = [ + 'column1' => 'Custom Heading 1', + 'column2' => 'Custom Heading 2', + 'column3' => 'Custom Heading 3' + // Add more custom headings as needed +]; + +// Define your SQL query +$sql = "SELECT id, ac_reg, ac_type, ac_call, TIME_FORMAT(eta,'%H:%i') AS ETA, fuel, in_from, pob_in FROM submitted WHERE DATE(eta) = CURDATE() AND status = 'NEW' ORDER BY eta ASC;"; // Replace with your table name + +// Execute the query +$result = $conn->query($sql); + +// Check if there are results +if ($result->num_rows > 0) { + // Start HTML table + echo ' + + '; + + // Output table headers (assuming column names are known) + $fields = $result->fetch_fields(); + foreach ($fields as $field) { + if ($field->name != 'id' && $field->name != 'ac_call') { + echo ''; + } + + } + echo ''; + + echo ' + + '; + + // Output table rows + while ($row = $result->fetch_assoc()) { + echo ''; + foreach ($row as $key => $value) { + if ($key != 'id' && $key != 'ac_call') { + if ($key == 'ac_reg' && $row['ac_call'] != NULL) { + echo ''; + } else { + echo ''; + } + } + } + echo ''; + echo ''; + } + + echo '
' . htmlspecialchars($field->name ?? '') . 'actions
' . htmlspecialchars($row['ac_call'] ?? '') . "
" . $value . '
' . htmlspecialchars($value ?? '') . '
'; +} else { + echo "No results found."; +} + +// Close the database connection +$conn->close(); + +?> + +
+ + \ No newline at end of file diff --git a/webhook.php b/webhook.php new file mode 100644 index 0000000..52d6125 --- /dev/null +++ b/webhook.php @@ -0,0 +1,84 @@ +format('Y-m-d H:i:s'); +$pob_in = $json['data'][$fieldMap['pob_in']]['value']; + +if (array_key_exists($fieldMap['out_to'], $json['data'])) { + $date = DateTime::createFromFormat('d/m/Y H:i', $json['data'][$fieldMap['etd']]['value']); + $etd = $date->format('Y-m-d H:i:s'); + $pob_out = $json['data'][$fieldMap['pob_out']]['value']; + $out_to = $json['data'][$fieldMap['out_to']]['value']; +} + +$email = $json['data'][$fieldMap['email']]['value']; +$phone = $json['data'][$fieldMap['phone']]['value']; +$notes = $json['data'][$fieldMap['notes']]['value']; + +mysqli_stmt_bind_param($stmt, "ssssssisissss", $ac_reg, $ac_type, $captain, $fuel, $in_from, $eta, $pob_in, $etd, $pob_out, $email, $phone, $notes, $created_by); + +// Execute the statement +if (mysqli_stmt_execute($stmt)) { + error_log("Record inserted for " . $ac_reg); +} else { + error_log("Error: " . mysqli_stmt_error($stmt)); +} + +// Close the statement and connection +mysqli_stmt_close($stmt); +mysqli_close($mysqli); +?>