217 lines
6.4 KiB
PHP
217 lines
6.4 KiB
PHP
<?php
|
|
require_once __DIR__ . '/config.php';
|
|
session_start_safe();
|
|
|
|
$authenticated = !empty($_SESSION['access_token'])
|
|
&& ($_SESSION['token_expires'] ?? 0) > time();
|
|
|
|
$tokenExpired = !empty($_SESSION['access_token'])
|
|
&& ($_SESSION['token_expires'] ?? 0) <= time();
|
|
|
|
$error = $_GET['error'] ?? null;
|
|
$errorMessages = [
|
|
'access_denied' => 'Access denied — you declined the FFLogs authorization.',
|
|
'token_failed' => 'Could not retrieve access token from FFLogs. Please try again.',
|
|
'missing_code' => 'Authorization code missing in callback.',
|
|
];
|
|
$errorText = $error ? ($errorMessages[$error] ?? 'Unknown error: ' . htmlspecialchars($error)) : null;
|
|
$tokenDebug = $_SESSION['token_debug'] ?? null;
|
|
unset($_SESSION['token_debug']);
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>FFLogs Report Viewer</title>
|
|
<style>
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
body {
|
|
font-family: 'Courier New', Courier, monospace;
|
|
background: #1a1a1a;
|
|
color: #e0e0e0;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 2rem;
|
|
}
|
|
|
|
.container {
|
|
width: 100%;
|
|
max-width: 860px;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 1.2rem;
|
|
color: #a78bfa;
|
|
margin-bottom: 1.5rem;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
|
|
.error-box {
|
|
background: #3b0f0f;
|
|
border: 1px solid #7f1d1d;
|
|
color: #fca5a5;
|
|
padding: 0.75rem 1rem;
|
|
margin-bottom: 1.5rem;
|
|
border-radius: 2px;
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.info-box {
|
|
background: #1e2a1e;
|
|
border: 1px solid #365936;
|
|
color: #86efac;
|
|
padding: 0.75rem 1rem;
|
|
margin-bottom: 1.5rem;
|
|
border-radius: 2px;
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.btn {
|
|
display: inline-block;
|
|
padding: 0.6rem 1.4rem;
|
|
background: #7c3aed;
|
|
color: #fff;
|
|
text-decoration: none;
|
|
border: none;
|
|
cursor: pointer;
|
|
font-family: inherit;
|
|
font-size: 0.95rem;
|
|
border-radius: 2px;
|
|
letter-spacing: 0.03em;
|
|
transition: background 0.15s;
|
|
}
|
|
.btn:hover { background: #6d28d9; }
|
|
.btn-secondary {
|
|
background: #374151;
|
|
font-size: 0.85rem;
|
|
padding: 0.4rem 0.9rem;
|
|
margin-left: 1rem;
|
|
}
|
|
.btn-secondary:hover { background: #4b5563; }
|
|
|
|
.form-row {
|
|
display: flex;
|
|
gap: 0.75rem;
|
|
align-items: center;
|
|
margin-bottom: 1.5rem;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
input[type="text"], select {
|
|
flex: 1;
|
|
min-width: 180px;
|
|
padding: 0.55rem 0.75rem;
|
|
background: #111827;
|
|
border: 1px solid #374151;
|
|
color: #e0e0e0;
|
|
font-family: inherit;
|
|
font-size: 0.95rem;
|
|
border-radius: 2px;
|
|
outline: none;
|
|
}
|
|
input[type="text"]:focus, select:focus { border-color: #7c3aed; }
|
|
input[type="text"]::placeholder { color: #4b5563; }
|
|
select option { background: #111827; }
|
|
#fight-select-row { display: none; }
|
|
|
|
.terminal {
|
|
background: #0d0d0d;
|
|
border: 1px solid #2d2d2d;
|
|
color: #a3e635;
|
|
padding: 1.25rem;
|
|
min-height: 260px;
|
|
white-space: pre-wrap;
|
|
overflow-x: auto;
|
|
font-size: 0.85rem;
|
|
line-height: 1.55;
|
|
border-radius: 2px;
|
|
}
|
|
|
|
.footer-link {
|
|
margin-top: 1rem;
|
|
font-size: 0.8rem;
|
|
color: #4b5563;
|
|
}
|
|
.footer-link a { color: #6b7280; text-decoration: none; }
|
|
.footer-link a:hover { color: #9ca3af; }
|
|
|
|
.connect-area {
|
|
text-align: center;
|
|
}
|
|
.connect-area h1 { margin-bottom: 0.5rem; }
|
|
.connect-area p {
|
|
color: #6b7280;
|
|
margin-bottom: 1.5rem;
|
|
font-size: 0.9rem;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
|
|
<?php if ($errorText): ?>
|
|
<div class="error-box"><?= $errorText ?></div>
|
|
<?php endif; ?>
|
|
<?php if ($tokenDebug): ?>
|
|
<div class="error-box">
|
|
<strong>Debug — FFLogs Token Response:</strong><br>
|
|
HTTP <?= (int)$tokenDebug['http_status'] ?><?= $tokenDebug['curl_error'] ? ' | curl: ' . htmlspecialchars($tokenDebug['curl_error']) : '' ?><br>
|
|
<pre style="margin-top:0.5rem;white-space:pre-wrap;font-size:0.8rem;"><?= htmlspecialchars($tokenDebug['response_body'] ?? '(empty)') ?></pre>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!$authenticated && !$tokenExpired): ?>
|
|
<div class="connect-area">
|
|
<h1>// FFLogs Report Viewer</h1>
|
|
<p>Connect your FFLogs account to fetch report data.</p>
|
|
<a class="btn" href="auth/start.php">Connect to FFLogs</a>
|
|
</div>
|
|
|
|
<?php elseif ($tokenExpired): ?>
|
|
<div class="connect-area">
|
|
<h1>// FFLogs Report Viewer</h1>
|
|
<div class="info-box">Session expired. Please reconnect.</div>
|
|
<a class="btn" href="auth/start.php">Reconnect to FFLogs</a>
|
|
</div>
|
|
|
|
<?php else: ?>
|
|
<h1>// FFLogs Report Viewer</h1>
|
|
|
|
<form id="report-form">
|
|
<div class="form-row">
|
|
<input
|
|
type="text"
|
|
name="report_code"
|
|
placeholder="Report Code (e.g. aBcDeFgH1234)"
|
|
autocomplete="off"
|
|
spellcheck="false"
|
|
required
|
|
>
|
|
<button class="btn" type="submit">Fetch</button>
|
|
<a class="btn btn-secondary" href="auth/start.php">Reconnect</a>
|
|
</div>
|
|
</form>
|
|
|
|
<div class="form-row" id="fight-select-row">
|
|
<select id="fight-select">
|
|
<option value="">— Fight auswählen —</option>
|
|
</select>
|
|
</div>
|
|
|
|
<pre id="output" class="terminal">// paste a report code above and hit Fetch</pre>
|
|
|
|
<div class="footer-link">
|
|
Token valid until: <?= date('Y-m-d H:i:s', $_SESSION['token_expires']) ?>
|
|
</div>
|
|
|
|
<script src="js/app.js"></script>
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|