This repository has been archived on 2023-08-24. You can view files and clone it, but cannot push or open issues or pull requests.
athena.fb-infra.uk/report-issue/index.php

118 lines
3.3 KiB
PHP
Raw Normal View History

2022-09-16 20:31:29 +01:00
<!DOCTYPE html>
<html>
<head>
<title>Athena</title>
<meta charset="UTF-8"/>
<meta name="description" content="Athena - Quick links to live train departures for traincrew."/>
2022-09-16 21:26:17 +01:00
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2022-09-16 20:31:29 +01:00
<meta name="application-name" content="Athena">
<meta name="author" content="Frederick Boniface">
<link rel="stylesheet" type="text/css" href="/styles/style.css"/>
<link rel="icon" type="image/png" href="/assets/icons/favicon.ico"/>
</head>
<body>
2022-09-16 21:14:24 +01:00
<?php
2022-09-17 21:29:35 +01:00
// Define form variables and set to empty values (or to the UA)
2022-09-16 21:14:24 +01:00
$subject = $detail = "";
$ua_str = $_SERVER["HTTP_USER_AGENT"];
2022-09-17 21:22:05 +01:00
// Define response variable & data variable as blank before POSTing
2022-09-17 21:04:19 +01:00
$giteaResponse = "";
2022-09-17 21:22:05 +01:00
$issueData = "";
2022-09-17 21:04:19 +01:00
2022-09-17 21:29:35 +01:00
// If the page is loading after submission then run this:
2022-09-16 21:14:24 +01:00
if ($_SERVER["REQUEST_METHOD"] == "POST" ) {
$subject = validate($_POST["subject"]);
$detail = validate($_POST["detail"]);
2022-09-17 20:57:03 +01:00
// Get API Key for git.fjla.uk
$giteaKey = file_get_contents('/srv/php-keys/athena/gitea');
// Set httpHeaders
$httpHeaders = array(
"accept: application/json",
$giteaKey,
"Content-Type: application/json"
2022-09-17 20:58:16 +01:00
);
2022-09-17 20:57:03 +01:00
// Prepare $detail to POST
2022-09-18 20:32:11 +01:00
$body = "User Agent: " . $ua_str . "\n Server PHP Version: " . PHP_VERSION . "\n" . $detail;
2022-09-17 20:57:03 +01:00
// Prepare the request
2022-09-17 21:19:57 +01:00
$rawData = array(
'body' => $body,
'title' => $subject
2022-09-17 20:58:16 +01:00
);
2022-09-17 20:57:03 +01:00
2022-09-17 21:19:57 +01:00
$issueData = json_encode($rawData);
2022-09-17 20:57:03 +01:00
// Prepare CURL
$curlConnection = curl_init('https://git.fjla.uk/api/v1/repos/fred.boniface/athena.fb-infra.uk/issues');
curl_setopt($curlConnection, CURLOPT_POSTFIELDS, $issueData);
curl_setopt($curlConnection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlConnection, CURLOPT_HTTPHEADER, $httpHeaders);
// Get response and exit CURL
$giteaResponse = curl_exec($curlConnection);
curl_close($curlConnection);
2022-09-16 21:14:24 +01:00
}
function validate($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
2022-09-16 20:31:29 +01:00
<!-- Main Content Begins -->
<img class="titleimg" src="/assets/title/title.webp"></img>
<h1>Please help us fix your issue</h1>
<p>Give as much detail as possible so we can try to fix the problem.</p>
2022-09-16 21:23:23 +01:00
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
2022-09-16 20:36:34 +01:00
Subject:
<br>
2022-09-16 21:23:23 +01:00
<input type="text" name="subject" value="<?php echo $subject;?>">
2022-09-16 20:36:34 +01:00
<br>
2022-09-16 20:31:29 +01:00
<br>
Details:
<br>
2022-09-16 21:23:23 +01:00
<textarea name="detail" rows="5" cols="40"><?php echo $detail;?></textarea>
<br>
2022-09-16 20:44:28 +01:00
On submission of this form, your browsers User Agent string will be
collected alongside the information you provide above and will be
posted to git.fjla.uk/fred.boniface/athena.fb-infra.uk/issues.
<br>
2022-09-16 21:14:24 +01:00
<br>
Your user agent is:
<br>
<?php echo $ua_str; ?>
2022-09-16 21:04:34 +01:00
<br>
2022-09-16 21:18:36 +01:00
<br>
<input type="submit">
2022-09-16 20:31:29 +01:00
</form>
2022-09-17 20:57:03 +01:00
<p>You have submitted:</p>
2022-09-17 21:15:02 +01:00
<p>REQUEST DATA: <?php echo $issueData;?>
<br>
<br>
JSON REPLY: <?php echo $giteaResponse;?>
2022-09-17 21:10:24 +01:00
</p>
2022-09-17 20:57:03 +01:00
2022-09-16 20:31:29 +01:00
<!-- Footer -->
<footer>
2022-09-18 20:46:47 +01:00
<?php include "./../page-blocks/footer.php" ?>
2022-09-16 20:31:29 +01:00
</footer>
</body>
</html>