check.php auf 30 Spieltage begrenzt zum Debuggen, Tippen optimiert mit ein paar QoL Features, updaten von Tipps hinzugefügt
This commit is contained in:
53
bulitipp/tippsuser.php
Executable file
53
bulitipp/tippsuser.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Authorization");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
use Firebase\JWT\JWT;
|
||||
use Firebase\JWT\Key;
|
||||
|
||||
include("jwtsecret.php");
|
||||
include("../../mysqlverbinden.php");
|
||||
|
||||
$headers = getallheaders();
|
||||
if(isset($headers['Authorization'])) {
|
||||
$authHeader = $headers['Authorization'];
|
||||
if (preg_match('/Bearer\s(\S+)/', $authHeader, $matches)) {
|
||||
$token = $matches[1];
|
||||
} else {
|
||||
die("Invalid Authorization header format");
|
||||
}
|
||||
} else {
|
||||
die("Authorization header not found");
|
||||
}
|
||||
try{
|
||||
$payload = JWT::decode($token, new Key($secret, 'HS256'));
|
||||
}catch (Exception $e) {
|
||||
die("{}");
|
||||
}
|
||||
|
||||
$userid= $payload->id;
|
||||
|
||||
if($payload->exp < time()){
|
||||
die("Token abgelaufen");
|
||||
}
|
||||
|
||||
if(!isset($_GET["spieltag"])) die("GET spieltag fehlt");
|
||||
$spieltag = $_GET["spieltag"];
|
||||
|
||||
|
||||
$data=[];
|
||||
|
||||
for($i=0;$i<9;$i++){
|
||||
$tipp=mysqli_execute_query($db_id,"SELECT `paarung`, `score1`, `score2` FROM `buli-tipp` AS bt JOIN `buli-tipps` AS bts ON bts.tipp".($i+1)."=bt.id WHERE bt.`spieltag`=? AND bts.user=?;",[$spieltag,$userid])->fetch_assoc();
|
||||
array_push($data,$tipp);
|
||||
}
|
||||
|
||||
echo json_encode($data, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||
Reference in New Issue
Block a user