124 lines
3.5 KiB
PHP
124 lines
3.5 KiB
PHP
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Athena</title>
|
|
|
|
<meta charset="UTF-8"/>
|
|
<meta name="description" content="Athena - Quick links to live train departures for traincrew."/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<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>
|
|
|
|
<?php
|
|
// Define form variables and set to empty values (or to the UA)
|
|
$subject = $detail = "";
|
|
$ua_str = $_SERVER["HTTP_USER_AGENT"];
|
|
|
|
// Define response variable & data variable as blank before POSTing
|
|
$giteaResponse = "";
|
|
$issueData = "";
|
|
|
|
// If the page is loading after submission then run this:
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST" ) {
|
|
$subject = validate($_POST["subject"]);
|
|
$detail = validate($_POST["detail"]);
|
|
|
|
// 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"
|
|
);
|
|
|
|
// Prepare $detail to POST
|
|
$body = "User Agent: ", $ua_str, "\n Server PHP Version: ", PHP_VERSION, "\n", $detail;
|
|
|
|
// Prepare the request
|
|
$rawData = array(
|
|
'body' => $body,
|
|
'title' => $subject,
|
|
'closed' => 'false'
|
|
);
|
|
|
|
$issueData = json_encode($rawData);
|
|
|
|
// 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);
|
|
}
|
|
|
|
function validate($data) {
|
|
$data = trim($data);
|
|
$data = stripslashes($data);
|
|
$data = htmlspecialchars($data);
|
|
return $data;
|
|
}
|
|
?>
|
|
|
|
<!-- 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>
|
|
|
|
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
|
|
Subject:
|
|
<br>
|
|
<input type="text" name="subject" value="<?php echo $subject;?>">
|
|
<br>
|
|
<br>
|
|
Details:
|
|
<br>
|
|
<textarea name="detail" rows="5" cols="40"><?php echo $detail;?></textarea>
|
|
<br>
|
|
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>
|
|
<br>
|
|
Your user agent is:
|
|
<br>
|
|
<?php echo $ua_str; ?>
|
|
<br>
|
|
<br>
|
|
<input type="submit">
|
|
</form>
|
|
|
|
<p>You have submitted:</p>
|
|
<p>REQUEST DATA: <?php echo $issueData;?>
|
|
<br>
|
|
<br>
|
|
JSON REPLY: <?php echo $giteaResponse;?>
|
|
<br>
|
|
<br>
|
|
SUBJECT: <?php echo $subject;?>
|
|
<br>
|
|
DETAIL: <?php echo $detail;?>
|
|
</p>
|
|
|
|
<!-- Footer -->
|
|
<footer>
|
|
<p>Created by Fred Boniface - v0.4.0-devel</p>
|
|
</footer>
|
|
|
|
</body>
|
|
|
|
</html>
|